From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 399C8C433EF for ; Wed, 29 Sep 2021 13:42:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0772161353 for ; Wed, 29 Sep 2021 13:42:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0772161353 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wSASbn5jfFK2NbvbfowTIluheW5957M+/vxnLH55W1w=; b=ck7RX7H4mDFEGd 1L7Bub+8tBJK0Nf4FCz76myUw7XXH8xSvD52473wyBMR08l0qR61tEtlU6Nlk9tfkcrtnof6g05o/ taUprYvRx0RdLz/1FcVbYWB5GakpEkLkWZw7yOl/75Jv6Xmq3+ESHKKVth9Z6pSyX/J2SWv1DlL5N 3bGaO4ngO/bOBGRy2Gm9BI+QnlaTky+o0xQO0bxobr+OJz5Rk1jvUmd362le777fom1VqorQKph/U lBlZkMu0jh2yYu4ESsaLBrIgkcSpEvJnzui8Ju2MY7dkrudvX42gBE0QzUCKkn2O3iEEn2orv0SkR ZFUGn2pqG9RS4kfWKHhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVZpm-00BB9I-3B; Wed, 29 Sep 2021 13:41:18 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVZpj-00BB8h-4r for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 13:41:16 +0000 Received: by mail-wm1-x331.google.com with SMTP id s24so1888489wmh.4 for ; Wed, 29 Sep 2021 06:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8zTkbVm3Z8SpIKUtLyUq9LTghZR593e6SVoW4QuNd20=; b=AxUSXoBB3tfQRc8aFp3qs+NkR4akyD1opeDx5OBAxYf7bBFGb1HqX25oj6+k1NvtaQ R9gzgBYCJcKaiSfZoXWC0pqMCzly17i2jBs2xQ8Jur5GRFQ8+149QSXLUa0lkmleon4q 2XQ/wMo/QAb3s+25Kni2BXlUaSSaaoGxmpKCChPJM7/bK7FC27Oywc8yO1aW49TeP0Hp 79/ys06I6zm/wX8btcvzUe3Y0UFMsL4fJE8lBxAfobOzIj5OhrnUzMCzIkpNxbMWoBjM 80piIvv78GPVKgZED6TVqizKJMXnlm9NTTpHEFuFiIWu4mmEHPCyIPvAbDQCoEMntXyq WlmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8zTkbVm3Z8SpIKUtLyUq9LTghZR593e6SVoW4QuNd20=; b=5Jt3M162RO/bx9nyCAF+UtcdZeH7EZomQ/CY80M+XbQuCSq+GrRmdpVaQV1Yc5iyRJ cHfL5t8viTNa6RyW/DUf+kRvSJqTUdC+mf+Rc5Sp4vAsODeZZ4F3w6Sxvz+TQbRDwbo7 5KXeHKDFUpuj3nJG06TygMl9DQVt+yChHJjvhFlO5UuivVSdUQKVi6g8cuNnqLt3jFiL l0o0sxEqJrC5VkQvfvHMmyqiak985/26yfo+S7AMf8DQ/+lO3iO00N9uQChCgaROryM4 dI2ZMe32x+966FSN1CdjQ54RBk3PFARPH6CjQ7TOnK1yi2FfolCjxN68rXsgwIVPtA2S dKZg== X-Gm-Message-State: AOAM531tqfVuEcOEqP+3tJ2c4qtPLZg0CdGFiHRNTWmz6L3qoPOtpAyd QUpALcFjXBQfHkS+niuiu7okoQ== X-Google-Smtp-Source: ABdhPJyiEDyoR1KgDk/hdilL8nWV/fMgBRNsKeMkLMofDuNYSGHNUhEe8kaPI7XdOFqMRNFm1cWREg== X-Received: by 2002:a1c:2348:: with SMTP id j69mr10228371wmj.189.1632922873028; Wed, 29 Sep 2021 06:41:13 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:1ebb:fd0f:cf53:11c5]) by smtp.gmail.com with ESMTPSA id z8sm2696973wrm.63.2021.09.29.06.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:41:12 -0700 (PDT) Date: Wed, 29 Sep 2021 14:41:10 +0100 From: Quentin Perret To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Catalin Marinas , Alexandru Elisei , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH 4/5] KVM: arm64: Prevent re-finalisation of pKVM for a given CPU Message-ID: References: <20210923112256.15767-1-will@kernel.org> <20210923112256.15767-5-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210923112256.15767-5-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_064115_210478_F77D5611 X-CRM114-Status: GOOD ( 19.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thursday 23 Sep 2021 at 12:22:55 (+0100), Will Deacon wrote: > __pkvm_prot_finalize() completes the deprivilege of the host when pKVM > is in use by installing a stage-2 translation table for the calling CPU. > > Issuing the hypercall multiple times for a given CPU makes little sense, > but in such a case just return early with -EPERM rather than go through > the whole page-table dance again. > > Cc: Marc Zyngier > Cc: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > index bacd493a4eac..cafe17e5fa8f 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > @@ -123,6 +123,9 @@ int __pkvm_prot_finalize(void) > struct kvm_s2_mmu *mmu = &host_kvm.arch.mmu; > struct kvm_nvhe_init_params *params = this_cpu_ptr(&kvm_init_params); > > + if (params->hcr_el2 & HCR_VM) > + return -EPERM; And you check this rather than the static key because we flip it upfront I guess. Makes sense to me, but maybe a little comment would be useful :) In any case: Reviewed-by: Quentin Perret Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel