Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp437681imp; Thu, 21 Feb 2019 04:35:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IaBLm5vFxuFTQAbwzS4mqSvuWEXBYFQofXcvVbwayipYc71LcLdjDIamce9EXwJLVTXlGWC X-Received: by 2002:a62:1bd4:: with SMTP id b203mr39696793pfb.144.1550752519902; Thu, 21 Feb 2019 04:35:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550752519; cv=none; d=google.com; s=arc-20160816; b=KqItTc3yFNBiWyWqjb5fdC4VmYMOT3HFUT8S1h5QbtoZSlGdWfZzzqWiFtuvvNrTjp X71ZTDJDylBW1dLNhJv4/guLjNj3XSUUtGCrgH4RfGQPqb6uXHHcmTFmpWoOBFPaINZT UCcKs5H2gCj2Bwq7ccUiBpUQYVH1Jf0SnRjjUnsQeb8HpPXVWKqvjM/JOY67AkXTcOnB HjzsEB1DaHPOjYj9VxjJeXH5fWtp0XPfYZbSEky8n3z+VX+7Evn/adyF+EaRJAGrjVir jIz0JaTWyOY5sa+d4Z+QBYd6XbkyLmvaes7KcWR7UMZH18GtWDgv1MBtNyO0hgdGXifg RcEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=cAF1PKNvMZwsbliZ/HUvvJvID+vOivsz9IG0113H3Ow=; b=BJQu1jVrMzDrfwHM2ETs+fkQdyMxdQAlUtYmkeogflGf0D/r07eC3XhA1I4P8PUuYB vsmOVN3XrtSr/1Y7rufi4YddeunSmqsjtfRguzl7ammBgvHiRcAOqTMZIPYej4GV84FS oG8YZl4Dw6HTZR3YRNHc9nfa584wngE5SbvGhaARbtmDhqgVX8WgWMx4jQ3UDEhtcQU3 ZPKcA5qKaVoaLRNXmL/eqeljU11nP179cijJZOPZQZ2JhdEB4Zu13jv3OSNicmK5t51A JIAKh6WVdHkuHqY5QoKL9BwGlujTbqJ20kktfGG1NJpYEViVs4gyf1nOhVw8AnB9IeSi YqZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si20500291pfi.286.2019.02.21.04.35.04; Thu, 21 Feb 2019 04:35:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbfBUMeX (ORCPT + 99 others); Thu, 21 Feb 2019 07:34:23 -0500 Received: from foss.arm.com ([217.140.101.70]:43664 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbfBUMeW (ORCPT ); Thu, 21 Feb 2019 07:34:22 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06E1080D; Thu, 21 Feb 2019 04:34:22 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 695383F575; Thu, 21 Feb 2019 04:34:19 -0800 (PST) Date: Thu, 21 Feb 2019 12:34:16 +0000 From: Mark Rutland To: Amit Daniel Kachhap Cc: linux-arm-kernel@lists.infradead.org, Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Andrew Jones , Dave Martin , Ramana Radhakrishnan , kvmarm@lists.cs.columbia.edu, Kristina Martsenko , linux-kernel@vger.kernel.org, James Morse , Julien Thierry Subject: Re: [PATCH v6 4/6] arm64/kvm: add a userspace option to enable pointer authentication Message-ID: <20190221123416.GD33673@lakrids.cambridge.arm.com> References: <1550568271-5319-1-git-send-email-amit.kachhap@arm.com> <1550568271-5319-5-git-send-email-amit.kachhap@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1550568271-5319-5-git-send-email-amit.kachhap@arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 19, 2019 at 02:54:29PM +0530, Amit Daniel Kachhap wrote: > This feature will allow the KVM guest to allow the handling of > pointer authentication instructions or to treat them as undefined > if not set. It uses the existing vcpu API KVM_ARM_VCPU_INIT to > supply this parameter instead of creating a new API. > > A new register is not created to pass this parameter via > SET/GET_ONE_REG interface as just a flag (KVM_ARM_VCPU_PTRAUTH) > supplied is enough to enable this feature. > > Signed-off-by: Amit Daniel Kachhap > Cc: Mark Rutland > Cc: Marc Zyngier > Cc: Christoffer Dall > Cc: kvmarm@lists.cs.columbia.edu > --- > Documentation/arm64/pointer-authentication.txt | 9 +++++---- > Documentation/virtual/kvm/api.txt | 4 ++++ > arch/arm64/include/asm/kvm_host.h | 3 ++- > arch/arm64/include/uapi/asm/kvm.h | 1 + > arch/arm64/kvm/handle_exit.c | 2 +- > arch/arm64/kvm/hyp/ptrauth-sr.c | 16 +++++++++++++++- > arch/arm64/kvm/reset.c | 3 +++ > arch/arm64/kvm/sys_regs.c | 26 +++++++++++++------------- > include/uapi/linux/kvm.h | 1 + > 9 files changed, 45 insertions(+), 20 deletions(-) > > diff --git a/Documentation/arm64/pointer-authentication.txt b/Documentation/arm64/pointer-authentication.txt > index a25cd21..0529a7d 100644 > --- a/Documentation/arm64/pointer-authentication.txt > +++ b/Documentation/arm64/pointer-authentication.txt > @@ -82,7 +82,8 @@ pointers). > Virtualization > -------------- > > -Pointer authentication is not currently supported in KVM guests. KVM > -will mask the feature bits from ID_AA64ISAR1_EL1, and attempted use of > -the feature will result in an UNDEFINED exception being injected into > -the guest. > +Pointer authentication is enabled in KVM guest when virtual machine is > +created by passing a flag (KVM_ARM_VCPU_PTRAUTH) requesting this feature > +to be enabled. Without this flag, pointer authentication is not enabled > +in KVM guests and attempted use of the feature will result in an UNDEFINED > +exception being injected into the guest. > diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt > index 356156f..1e646fb 100644 > --- a/Documentation/virtual/kvm/api.txt > +++ b/Documentation/virtual/kvm/api.txt > @@ -2642,6 +2642,10 @@ Possible features: > Depends on KVM_CAP_ARM_PSCI_0_2. > - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU. > Depends on KVM_CAP_ARM_PMU_V3. > + - KVM_ARM_VCPU_PTRAUTH: Emulate Pointer authentication for the CPU. > + Depends on KVM_CAP_ARM_PTRAUTH and only on arm64 architecture. If > + set, then the KVM guest allows the execution of pointer authentication > + instructions. Otherwise, KVM treats these instructions as undefined. I think that we should have separate flags for address auth and generic auth, to match the ID register split. For now, we can have KVM only support the case where both are set, but it gives us freedom to support either in isolation if we have to in future, without an ABI break. Thanks, Mark.