Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp792805imj; Fri, 15 Feb 2019 06:56:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IbLHC9wxSzTcpuX/y8RDToiACzSrSwTV49w/h8r72erRW8WJlVxKjyfBBKCDfyv0cYxRe/G X-Received: by 2002:a17:902:8641:: with SMTP id y1mr10546320plt.159.1550242609493; Fri, 15 Feb 2019 06:56:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550242609; cv=none; d=google.com; s=arc-20160816; b=WSrxr0M+2hE4CxhTYgzuGce+BIG+DClL44oInLjweEEMhZK39QPLdsOrqzsSsKXFvH 8G088TSJUxyaIfxbooouM37C+yWkI+mrR6PXSkRQIVoXA/nzJ99kjD+EWPPnjVvxPvnD FhHdIWhQMvATP/8IdO/E7EC+BWY/54J2VuWDJPxqeMyAYpVaHs0e+hbERlgCc3crQ9du zV0mKNpzn1QNoeduXhNssEDgbPM7CDG6gytnHzA1FS4LlvojhMK6yjY/87RAy6OfiHGd CJb5nrPWOJH5Y2pqB/e3yiBVlPgFdPD7lcYVjtL+GFG+djjWB4EbvbxycpeAjeiObU5m vfKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=FSAtoQpfy2OfBl/hvT2k7r6zAscgvJblOCaRupOXrA8=; b=uj27dWfIrPjLs2kPLd7DvyIFGLNL4ljj3s19WwqRxNstwSKZck5OOmna9Y51BBRTxQ cDOzjJ57PEdV/o1yU1nx6B0YanqmjBSnf/hM0Lg2PS/P+9azsGI65KQNRl6THuGIkwvW rT86WJj6akSAL9VlOIvHirFdZLF9RJ/RNfyzCVAfeQVz2Yiol500Vk4fTGeVQSr2cUCc NA5Gmkj8P64B7e6cDhcUC7qQ3Wd9b/IwgN7qGZ2x34UUbsqOFrGfjg7JeeqJMX1MQRCL X9lWqm0jm5tSBjQG+9VM7a6GuScZmPcA7E3v6gUzPsWM2ZL3dV82wYqSfe/0SoH5BX8f yY7g== 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 f1si5132404pgs.104.2019.02.15.06.56.33; Fri, 15 Feb 2019 06:56:49 -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 S1731493AbfBOEtp (ORCPT + 99 others); Thu, 14 Feb 2019 23:49:45 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54568 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfBOEto (ORCPT ); Thu, 14 Feb 2019 23:49:44 -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 EA741A78; Thu, 14 Feb 2019 20:49:43 -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 9513D3F589; Thu, 14 Feb 2019 20:49:40 -0800 (PST) Subject: Re: [PATCH v5 4/5] arm64/kvm: add a userspace option to enable pointer authentication To: Kristina Martsenko , 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> From: Amit Daniel Kachhap Message-ID: <6f341bd4-299b-8cc5-2509-f3598a78e4c6@arm.com> Date: Fri, 15 Feb 2019 10:19:38 +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-Type: text/plain; charset=utf-8; format=flowed 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 Hi, On 2/13/19 11:05 PM, Kristina Martsenko wrote: > 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? Yes not required. Nice catch. > >> +/** >> + * 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? Yes makes sense. I missed it and with Dave martin patch this may be done cleanly. Thanks, Amit D > > Thanks, > Kristina >