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=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 CF66BC4363A for ; Wed, 28 Oct 2020 10:05:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 36CF7246A7 for ; Wed, 28 Oct 2020 10:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hMVoFW1+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lqD72N+g"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Quj9xe/w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36CF7246A7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cyJuIZoq1T/+PP28vAgS/IP1KSgzlfAOBJU7h15RVl8=; b=hMVoFW1+djNg+Yiwcr5L3G/T/ QOf2MVVme7qMm7myFvpzeCqZOJJeph3GrjRGd7k0/wpp4sgSMgw3z0AIghHtJa43XwVy47ONsIlCE jz58v+mNAJq1T/gmAb89yL5zul0VHEwZY6GpfmkSDaY/7UDfSgovB+UBn6hTJVEqmqAz41xFmR2ae KqhGgMW+dtCeMMpK/F5Z7K4kw5b64Q+x+zmj4ABZmMUDHFLRJwKFyc7HvB/GnPivdJ+KsN/4egimw Ezz6xlwPagEG7rXf9Ac52b0Tv6/YCOuRIitBYebbI8t1UdsieeEMZmB+q507436TXtQo8htt/2geF sCby15GMw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXiJO-0003hr-E5; Wed, 28 Oct 2020 10:04:10 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXiJI-0003gi-HU for linux-arm-kernel@merlin.infradead.org; Wed, 28 Oct 2020 10:04:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-ID:References:In-Reply-To: Subject:Cc:To:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version: Sender:Reply-To:Content-ID:Content-Description; bh=2SBuPYnVO5v+sl7ov4Dlv/yB6c8BJgeJsFw+70NS3L8=; b=lqD72N+gxsoGAVip5taw0TKZhQ spIlxyQ1OeTMSJyC4Bcg6hPiQ4w4YhC7wQdr5UMOO2iPLfSjM04JcCcG2Fll0/4sCiqHxWheYxGK3 yTBHLCD6cHJoVfiTp4G9IMeB9t35Mb/ZfJZfy7xVYMlcXfzfU5gCENIMaaJoGLcXk/T4Bt6GCb2p4 zUp09DBSfba9/jG0RCnnYZ3KyOq8ByDUNO2I7M7vCXAZeKgP8mUlxQIM4GqhXwXnH7a7Br+c3rE44 kLsbYqN9Xozwjm5fYsulC2WuHpG0NYgjjb6SxXslQe2A9HsLKz+iK8NPXA1Nhg9h9nd/vKrNUDb3z gQGcY7TQ==; Received: from mail.kernel.org ([198.145.29.99]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXiJD-0004gx-A9 for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2020 10:04:03 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E4C1A246A5; Wed, 28 Oct 2020 10:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603879432; bh=NQhHQntLZbnUoS/6yc85poCYnBYFJB0tEBEoFqmqy00=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Quj9xe/wOc2qoLkwpTkRu8kIGxN+5+Zi3TDhn8yy78/ocub3k4+QHI3CIO/oKpqZc 32xw0NGlkrwLeWAN26hnncv/68VVX9pJZia/iMoSzI2FFq3yt0ckWHtrOg3exEjslz XRJ9TXyJAsjshRSW4E2cTqU9vM/gnKoz1cYTMsiQ= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kXiJ3-0053dT-NI; Wed, 28 Oct 2020 10:03:49 +0000 MIME-Version: 1.0 Date: Wed, 28 Oct 2020 10:03:49 +0000 From: Marc Zyngier To: Will Deacon Subject: Re: [PATCH v3] KVM: arm64: ARM_SMCCC_ARCH_WORKAROUND_1 doesn't return SMCCC_RET_NOT_REQUIRED In-Reply-To: <20201026132533.GC24349@willie-the-truck> References: <20201023154751.1973872-1-swboyd@chromium.org> <20201026132533.GC24349@willie-the-truck> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <5e9bded886e31f7c7aaee195e6c373e1@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: will@kernel.org, swboyd@chromium.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, andre.przywara@arm.com, steven.price@arm.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201028_100359_975452_48836622 X-CRM114-Status: GOOD ( 23.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Steven Price , Andre Przywara , Stephen Boyd , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-10-26 13:25, Will Deacon wrote: > On Fri, Oct 23, 2020 at 08:47:50AM -0700, Stephen Boyd wrote: >> According to the SMCCC spec[1](7.5.2 Discovery) the >> ARM_SMCCC_ARCH_WORKAROUND_1 function id only returns 0, 1, and >> SMCCC_RET_NOT_SUPPORTED. >> >> 0 is "workaround required and safe to call this function" >> 1 is "workaround not required but safe to call this function" >> SMCCC_RET_NOT_SUPPORTED is "might be vulnerable or might not be, who >> knows, I give up!" >> >> SMCCC_RET_NOT_SUPPORTED might as well mean "workaround required, >> except >> calling this function may not work because it isn't implemented in >> some >> cases". Wonderful. We map this SMC call to >> >> 0 is SPECTRE_MITIGATED >> 1 is SPECTRE_UNAFFECTED >> SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE >> >> For KVM hypercalls (hvc), we've implemented this function id to return >> SMCCC_RET_NOT_SUPPORTED, 0, and SMCCC_RET_NOT_REQUIRED. One of those >> isn't supposed to be there. Per the code we call >> arm64_get_spectre_v2_state() to figure out what to return for this >> feature discovery call. >> >> 0 is SPECTRE_MITIGATED >> SMCCC_RET_NOT_REQUIRED is SPECTRE_UNAFFECTED >> SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE >> >> Let's clean this up so that KVM tells the guest this mapping: >> >> 0 is SPECTRE_MITIGATED >> 1 is SPECTRE_UNAFFECTED >> SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE >> >> Note: SMCCC_RET_NOT_AFFECTED is 1 but isn't part of the SMCCC spec >> >> Cc: Andre Przywara >> Cc: Steven Price >> Cc: Marc Zyngier >> Cc: stable@vger.kernel.org >> Link: https://developer.arm.com/documentation/den0028/latest [1] >> Fixes: c118bbb52743 ("arm64: KVM: Propagate full Spectre v2 workaround >> state to KVM guests") >> Signed-off-by: Stephen Boyd >> --- >> >> I see that before commit c118bbb52743 ("arm64: KVM: Propagate full >> Spectre v2 workaround state to KVM guests") we had this mapping: >> >> 0 is SPECTRE_MITIGATED >> SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE >> >> so the return value '1' wasn't there then. Once the commit was merged >> we >> introduced the notion of NOT_REQUIRED here when it shouldn't have been >> introduced. >> >> Changes from v2: >> * Moved define to header file and used it >> >> Changes from v1: >> * Way longer commit text, more background (sorry) >> * Dropped proton-pack part because it was wrong >> * Rebased onto other patch accepted upstream >> >> arch/arm64/kernel/proton-pack.c | 2 -- >> arch/arm64/kvm/hypercalls.c | 2 +- >> include/linux/arm-smccc.h | 2 ++ >> 3 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/arch/arm64/kernel/proton-pack.c >> b/arch/arm64/kernel/proton-pack.c >> index 25f3c80b5ffe..c18eb7d41274 100644 >> --- a/arch/arm64/kernel/proton-pack.c >> +++ b/arch/arm64/kernel/proton-pack.c >> @@ -135,8 +135,6 @@ static enum mitigation_state >> spectre_v2_get_cpu_hw_mitigation_state(void) >> return SPECTRE_VULNERABLE; >> } >> >> -#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED (1) >> - >> static enum mitigation_state >> spectre_v2_get_cpu_fw_mitigation_state(void) >> { >> int ret; >> diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c >> index 9824025ccc5c..25ea4ecb6449 100644 >> --- a/arch/arm64/kvm/hypercalls.c >> +++ b/arch/arm64/kvm/hypercalls.c >> @@ -31,7 +31,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) >> val = SMCCC_RET_SUCCESS; >> break; >> case SPECTRE_UNAFFECTED: >> - val = SMCCC_RET_NOT_REQUIRED; >> + val = SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED; >> break; >> } >> break; >> diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h >> index 15c706fb0a37..0e50ba3e88d7 100644 >> --- a/include/linux/arm-smccc.h >> +++ b/include/linux/arm-smccc.h >> @@ -86,6 +86,8 @@ >> ARM_SMCCC_SMC_32, \ >> 0, 0x7fff) >> >> +#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1 > > I thought we'd stick this in asm/spectre.h, but here is also good: > > Acked-by: Will Deacon Acked-by: Marc Zyngier Will, if you're about to send fixes to Linus, can you please pick this one up? M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel