Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30618821rwd; Thu, 6 Jul 2023 08:21:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlFk2NoN1Di/XWSUSfG2ggedJ1AXfcnJgRnope33CXNBvRauS1BqQhTSpmPNuLPXl6pCXLZu X-Received: by 2002:a17:90a:e50b:b0:263:21d6:906b with SMTP id t11-20020a17090ae50b00b0026321d6906bmr1983211pjy.14.1688656887841; Thu, 06 Jul 2023 08:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688656887; cv=none; d=google.com; s=arc-20160816; b=jeZLUS24VGFn2jdZlP3M0O371ELHnO+Z4PxsUJmJ/5gyZEmd18UxYnhJAs6GNdmYF9 dhSipnSyShcocowXVn6cxGRSrR6yBb8dT+wAdns8nqvaaUYiz6t8oErd12yUDpvRFSSA biQEUpWfa0sWahWS2RSttd0lzX8WjrSvP7RcU9Vj0eLgegXqfJdOHzLVpiSesYTiEks5 sEkNf6dS3UM9S7m07BTATGNTBH8xuqze4Xqzb0OcU6vXOf6T34QAlKKexfqsnjz0+Lwr /gMuKWal5o3mg5DYbG9aDk6tJ7/Ywk7KIuc9dapjt4PBVka41N/DYIRSeU02P+yr96yu E9kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=aYxf0yE0sp3Ut7y+049xqrjJwXN6/0J19fq/pM/YScM=; fh=lrcKtNIZ8cS8RIQ1kUFwPg7KFvAVT6IcEfSzvXPJoOQ=; b=Php78bXqDXN+emcn2F7DazxwPGYEoYywtUh44Z7chhA3OIx5gMYprAHd7x4kFt9d+S 07UvIu1jpdqPx1W+5fVM8xDRuauwz5nsFDmgkAHkBqzR7jD10kTeM5QMcn0+zyiV+L6F 6NGjWQ4XLGVrOlrv6J5v1squlB/NJsB/yi6xoxvtPiKde8GJTCqR6aHJ3aREam/GsOe2 a+Be75Hf2ooZPyYZnfakzH2zKp9egSosuR89YDAnRYRpNZCHrnlBjlyAj0ueP1boY8Rg yxiNehSZT6JyF8xidLmM0870pkPncIJ7miE4nPPKkvUFpsoWAlkdGYo6arhy3obC0AJd HcFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BhAi0ogw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a17090a8d0300b00263f5f3b890si1713180pjo.69.2023.07.06.08.21.10; Thu, 06 Jul 2023 08:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BhAi0ogw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231706AbjGFO1v (ORCPT + 99 others); Thu, 6 Jul 2023 10:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjGFO1t (ORCPT ); Thu, 6 Jul 2023 10:27:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A6710F5 for ; Thu, 6 Jul 2023 07:27:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DC4AF61983 for ; Thu, 6 Jul 2023 14:27:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 449FFC433C7; Thu, 6 Jul 2023 14:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688653667; bh=XjMcz5uZNstuRDH3jnBWjbSJFiV7skHvPFlp98zFaNI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BhAi0ogwapMqRb9bpapU3oUWnc7D4mZZ/5AokTrCdVsbl2BdVT8SJyQdWKJ+VC1Fk v3yy86953vnQPJI3nGDoREpbFSt8as5YUGBSRKx6AsGMRkOXbAlZXdjOyJrIkORYCy YeStLA8+YflkUTqkGJ2lhVq41/1NhacWHTx9CmjetWfE5r29mJEypyKVd5TALcIRqE sbdye9kHbOYkLY8kkdLUmu3n/B5k9EilXDMNcXRHCw7SjWfu+v4M3t41dvaD+kpt/e G0Rk0/05pAAoDhG2BAHT04XZKysR7Jp7Do3dbLTpbyzw52RVthudlnw7wFAoMlqFAX 5N9P0FJZD55xw== Received: from 84-53-99-172.bbserv.nl ([84.53.99.172] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qHPxQ-00AxTm-Ul; Thu, 06 Jul 2023 15:27:45 +0100 Date: Thu, 06 Jul 2023 15:27:36 +0100 Message-ID: <873521yv1j.wl-maz@kernel.org> From: Marc Zyngier To: Mostafa Saleh Cc: oliver.upton@linux.dev, Sudeep Holla , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, tabba@google.com, qperret@google.com, will@kernel.org, catalin.marinas@arm.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, james.morse@arm.com, bgardon@google.com, gshan@redhat.com Subject: Re: [PATCH v3] KVM: arm64: Use BTI for nvhe In-Reply-To: References: <20230530150845.2856828-1-smostafa@google.com> <20230704134136.a5znw4jupt5yp5kg@bogus> <20230704143339.cqrvntq7rmmb2on3@bogus> <20230704192529.d4x2p7ndz2dc4q52@bogus> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 84.53.99.172 X-SA-Exim-Rcpt-To: smostafa@google.com, oliver.upton@linux.dev, sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, tabba@google.com, qperret@google.com, will@kernel.org, catalin.marinas@arm.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, james.morse@arm.com, bgardon@google.com, gshan@redhat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mostafa, On Thu, 06 Jul 2023 13:49:04 +0100, Mostafa Saleh wrote: > > Hi Marc and Oliver, > > I was double checking that nothing else was missed. > > I found there is another problem for hw that has BTI and is affected > by specterv3a. > > "br'' instructions are generated at runtime for the vector > table(__bp_harden_hyp_vecs). These branches would land on vectors > in __kvm_hyp_vector at offset 8. > > As all the macros are defined with valid_vect/invalid_vect, it is > sufficient to add "bti j" there at the correct offset. > > I am not sure if such hardware exists. I tested this with a stubbed > "has_spectre_v3a" which confirms the issue and the fix. Thanks for the heads up. Fortunately, there is no such HW as far as I can tell. Only Cortex-A57 and A72 are affected by this (and the only two CPUs for which we engage the mitigation), and they are way too old to know about BTI. > Please let me know if this fix suitable, I can include it with the other fix in > "[PATCH] KVM: arm64: Add missing BTI instruction in kvm_host_psci_cpu_entry" > > diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S > index 8f3f93fa119e..175c030379e3 100644 > --- a/arch/arm64/kvm/hyp/hyp-entry.S > +++ b/arch/arm64/kvm/hyp/hyp-entry.S > @@ -154,6 +154,12 @@ SYM_CODE_END(\label) > esb > stp x0, x1, [sp, #-16]! > 662: > + /* > + * Specter vectors __bp_harden_hyp_vecs generate br instructions at runtime > + * that jump at offset 8 at __kvm_hyp_vector. > + * As hyp .text is guarded section, it needs bti j. > + */ > + bti j > b \target > > check_preamble_length 661b, 662b > @@ -165,6 +171,8 @@ check_preamble_length 661b, 662b > nop > stp x0, x1, [sp, #-16]! > 662: > + /* Check valid_vect */ > + bti j > b \target > > check_preamble_length 661b, 662b This looks correct to me. If you can respin you initial patch (with maybe a slightly more generic subject) so that Oliver can pick it up as part of the next batch of fixes, that'd be great. Thanks, M. -- Without deviation from the norm, progress is not possible.