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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D662C433E0 for ; Mon, 15 Jun 2020 10:25:38 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 3CC6A206D7 for ; Mon, 15 Jun 2020 10:25:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CC6A206D7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id AE59D4B0D5; Mon, 15 Jun 2020 06:25:37 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XI1waDwnHZJ6; Mon, 15 Jun 2020 06:25:36 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 94A334B0A0; Mon, 15 Jun 2020 06:25:36 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 9A2E14B0A0 for ; Mon, 15 Jun 2020 06:25:34 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F-dxBjj2nR95 for ; Mon, 15 Jun 2020 06:25:33 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 67BEA4B097 for ; Mon, 15 Jun 2020 06:25:33 -0400 (EDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 092D81F1; Mon, 15 Jun 2020 03:25:33 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.7.221]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15F323F71F; Mon, 15 Jun 2020 03:25:31 -0700 (PDT) Date: Mon, 15 Jun 2020 11:25:29 +0100 From: Mark Rutland To: Marc Zyngier Subject: Re: [PATCH 4/4] KVM: arm64: Check HCR_EL2 instead of shadow copy to swap PtrAuth registers Message-ID: <20200615102529.GD773@C02TD0UTHF1T.local> References: <20200615081954.6233-1-maz@kernel.org> <20200615081954.6233-5-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200615081954.6233-5-maz@kernel.org> Cc: kernel-team@android.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Mon, Jun 15, 2020 at 09:19:54AM +0100, Marc Zyngier wrote: > When save/restoring PtrAuth registers between host and guest, it is > pretty useless to fetch the in-memory state, while we have the right > state in the HCR_EL2 system register. Use that instead. > > Signed-off-by: Marc Zyngier It took me a while to spot that we switched the guest/host hcr_el2 value in the __activate_traps() and __deactivate_traps() paths, but given that this is only called in the __kvm_vcpu_run_*() paths called between those, I agree this is sound. Given that: Acked-by: Mark Rutland Mark. > --- > arch/arm64/include/asm/kvm_ptrauth.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_ptrauth.h b/arch/arm64/include/asm/kvm_ptrauth.h > index 6301813dcace..f1830173fa9e 100644 > --- a/arch/arm64/include/asm/kvm_ptrauth.h > +++ b/arch/arm64/include/asm/kvm_ptrauth.h > @@ -74,7 +74,7 @@ alternative_if_not ARM64_HAS_ADDRESS_AUTH_IMP_DEF > b 1001f > alternative_else_nop_endif > 1000: > - ldr \reg1, [\g_ctxt, #(VCPU_HCR_EL2 - VCPU_CONTEXT)] > + mrs \reg1, hcr_el2 > and \reg1, \reg1, #(HCR_API | HCR_APK) > cbz \reg1, 1001f > add \reg1, \g_ctxt, #CPU_APIAKEYLO_EL1 > @@ -90,7 +90,7 @@ alternative_if_not ARM64_HAS_ADDRESS_AUTH_IMP_DEF > b 2001f > alternative_else_nop_endif > 2000: > - ldr \reg1, [\g_ctxt, #(VCPU_HCR_EL2 - VCPU_CONTEXT)] > + mrs \reg1, hcr_el2 > and \reg1, \reg1, #(HCR_API | HCR_APK) > cbz \reg1, 2001f > add \reg1, \g_ctxt, #CPU_APIAKEYLO_EL1 > -- > 2.27.0 > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm