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=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,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 788A9C282C2 for ; Wed, 13 Feb 2019 17:35:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 572CE2175B for ; Wed, 13 Feb 2019 17:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393104AbfBMRf2 (ORCPT ); Wed, 13 Feb 2019 12:35:28 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57940 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732687AbfBMRf1 (ORCPT ); Wed, 13 Feb 2019 12:35:27 -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 41790A78; Wed, 13 Feb 2019 09:35:27 -0800 (PST) Received: from [10.1.197.21] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0B3333F675; Wed, 13 Feb 2019 09:35:23 -0800 (PST) From: Kristina Martsenko Subject: Re: [PATCH v5 4/5] arm64/kvm: add a userspace option to enable pointer authentication To: Amit Daniel Kachhap , linux-arm-kernel@lists.infradead.org Cc: Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Andrew Jones , Dave Martin , Ramana Radhakrishnan , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Mark Rutland References: <1548658727-14271-1-git-send-email-amit.kachhap@arm.com> <1548658727-14271-5-git-send-email-amit.kachhap@arm.com> Message-ID: Date: Wed, 13 Feb 2019 17:35:22 +0000 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: <1548658727-14271-5-git-send-email-amit.kachhap@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/01/2019 06:58, 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. [...] > diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h > index b200c14..b6950df 100644 > --- a/arch/arm/include/asm/kvm_host.h > +++ b/arch/arm/include/asm/kvm_host.h > @@ -346,6 +346,10 @@ static inline int kvm_arm_have_ssbd(void) > static inline void kvm_vcpu_load_sysregs(struct kvm_vcpu *vcpu) {} > static inline void kvm_vcpu_put_sysregs(struct kvm_vcpu *vcpu) {} > static inline void kvm_arm_vcpu_ptrauth_reset(struct kvm_vcpu *vcpu) {} > +static inline bool kvm_arm_vcpu_ptrauth_allowed(struct kvm_vcpu *vcpu) > +{ > + return false; > +} It seems like this is only ever called from arm64 code, so do we need an arch/arm/ definition? > +/** > + * kvm_arm_vcpu_ptrauth_allowed - checks if ptrauth feature is present in vcpu > + * > + * @vcpu: The VCPU pointer > + * > + * This function will be used to enable/disable ptrauth in guest as configured > + * by the KVM userspace API. > + */ > +bool kvm_arm_vcpu_ptrauth_allowed(struct kvm_vcpu *vcpu) > +{ > + return test_bit(KVM_ARM_VCPU_PTRAUTH, vcpu->arch.features); > +} I'm not sure, but should there also be something like if (test_bit(KVM_ARM_VCPU_PTRAUTH, vcpu->arch.features) && !kvm_supports_ptrauth()) return -EINVAL; in kvm_reset_vcpu? Thanks, Kristina