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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 CBDBEC43381 for ; Mon, 4 Mar 2019 10:56:46 +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 9D2B720823 for ; Mon, 4 Mar 2019 10:56:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="i9arps5O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D2B720823 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZEFC5Qj0vfGwUueo8oF79VVDCL2wGX+59Xtuukz7wEQ=; b=i9arps5OIE1XLJ6Rj3AYo+iS9 Bg9hg/21+9v9/G+VHOq3OVP/fedeEku8fE7G15id/+dyaaGBi+4pv29a+S5bYJcfBIqn7a1wZCwtN Irlq6oLgm2RLTDXvGF16x0jSC8W7h2R/cjo1MQwmo6pIjQKIPBZnAl7pgca7Xn7o4gSin2qAA6VS2 TFIwLmwuOoUtfmbV+lUT76J/uEmK9wg/s37aRNYjovnScnlr+9C1uylGuGWG7/Ol9rg4L68Q/df0u knSzIMQ7uas9BCLA4zUkB3qeLZ82j74vIiVIicDPeObX7nuPfff62V68kTO5eFES7Rvc4omQClg2q sWYlFf7pA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0lH3-0005WD-IJ; Mon, 04 Mar 2019 10:56:45 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0lGz-0005V5-LS for linux-arm-kernel@lists.infradead.org; Mon, 04 Mar 2019 10:56:43 +0000 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 0DAA4EBD; Mon, 4 Mar 2019 02:56:41 -0800 (PST) Received: from [10.162.0.144] (a075553-lin.blr.arm.com [10.162.0.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 185783F703; Mon, 4 Mar 2019 02:56:36 -0800 (PST) Subject: Re: [PATCH v6 4/6] arm64/kvm: add a userspace option to enable pointer authentication To: James Morse , linux-arm-kernel@lists.infradead.org References: <1550568271-5319-1-git-send-email-amit.kachhap@arm.com> <1550568271-5319-5-git-send-email-amit.kachhap@arm.com> From: Amit Daniel Kachhap Message-ID: <4e485492-50ef-3162-af3c-7af80b4a17cc@arm.com> Date: Mon, 4 Mar 2019 16:26:34 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190304_025641_713911_EED8F7ED X-CRM114-Status: GOOD ( 26.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Andrew Jones , Julien Thierry , Marc Zyngier , Catalin Marinas , Will Deacon , Christoffer Dall , Kristina Martsenko , kvmarm@lists.cs.columbia.edu, Ramana Radhakrishnan , Dave Martin , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi James, On 2/27/19 12:03 AM, James Morse wrote: > Hi Amit, > > On 19/02/2019 09:24, 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. > > and an attempt to restore the id register with the other version would fail. > > >> 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) > > (This is still mixing VM and VCPU) > > >> + requesting this feature to be enabled. > > .. on each vcpu? > > >> +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. > > 'guests' here suggests its a VM property. If you set it on some VCPU but not others KVM > will generate undefs instead of enabling the feature. (which is the right thing to do) > > I think it needs to be clear this is a per-vcpu property. ok. > > >> diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h >> index 97c3478..5f82ca1 100644 >> --- a/arch/arm64/include/uapi/asm/kvm.h >> +++ b/arch/arm64/include/uapi/asm/kvm.h >> @@ -102,6 +102,7 @@ struct kvm_regs { >> #define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */ >> #define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */ >> #define KVM_ARM_VCPU_PMU_V3 3 /* Support guest PMUv3 */ > >> +#define KVM_ARM_VCPU_PTRAUTH 4 /* VCPU uses address authentication */ > > Just address authentication? I agree with Mark we should have two bits to match what gets > exposed to EL0. One would then be address, the other generic. ok. > > >> diff --git a/arch/arm64/kvm/hyp/ptrauth-sr.c b/arch/arm64/kvm/hyp/ptrauth-sr.c >> index 528ee6e..6846a23 100644 >> --- a/arch/arm64/kvm/hyp/ptrauth-sr.c >> +++ b/arch/arm64/kvm/hyp/ptrauth-sr.c >> @@ -93,9 +93,23 @@ void kvm_arm_vcpu_ptrauth_reset(struct kvm_vcpu *vcpu) > >> +/** >> + * kvm_arm_vcpu_ptrauth_allowed - checks if ptrauth feature is allowed by user >> + * >> + * @vcpu: The VCPU pointer >> + * >> + * This function will be used to check userspace option to have ptrauth or not >> + * in the guest kernel. >> + */ >> +bool kvm_arm_vcpu_ptrauth_allowed(const struct kvm_vcpu *vcpu) >> +{ >> + return kvm_supports_ptrauth() && >> + test_bit(KVM_ARM_VCPU_PTRAUTH, vcpu->arch.features); >> +} > > This isn't used from world-switch, could it be moved to guest.c? yes sure. > > >> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c >> index 12529df..f7bcc60 100644 >> --- a/arch/arm64/kvm/sys_regs.c >> +++ b/arch/arm64/kvm/sys_regs.c >> @@ -1055,7 +1055,7 @@ static bool access_cntp_cval(struct kvm_vcpu *vcpu, >> } >> >> /* Read a sanitised cpufeature ID register by sys_reg_desc */ >> -static u64 read_id_reg(struct sys_reg_desc const *r, bool raz) >> +static u64 read_id_reg(struct kvm_vcpu *vcpu, struct sys_reg_desc const *r, bool raz) > > (It might be easier on the reviewer to move these mechanical changes to an earlier patch) Yes with including some of Dave SVE patches this wont be required. Thanks, Amit D > > > Looks good, > > Thanks, > > James > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel