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, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,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 375F5C433E1 for ; Thu, 23 Jul 2020 02:53:34 +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 F1EED206F4 for ; Thu, 23 Jul 2020 02:53:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fZX7p3ID"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D4Tjc4MS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1EED206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kOvNCgaoyRmdesPiu7/Gd7ZfDC78+V0VR5/adoxeHu0=; b=fZX7p3ID17K+JbMCTLkmsZmL7 6DVm2Z6zgm8nmEwUF7qsaCejtaUA86pqEfKg80vz1ghMZQ3n0LYHnc6HWAki4GYxqvlVToVMXNtGA lDSehg6DFkMVzXNdwD2DdSDjTvbm0zu/mt2FqIfgMr09GLb+rU2EB4WE74R8CxoMeLPaxpxlfNHUK G4N95wbYsuRScfC+zqp/DFV3C9YIWg/KQRu0dt39dCshEVjXB2l1Kfuu2POQXSxstLX4hdKolPcsm cwtQMlYKgOiHHv24KtV2i01Y3ixgD3JSFALYeqLb4NTQFI0EIy93fvbygUjFAP4dmz4E9Om8Dd0lS +PLP1Fr0w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyRKp-0000A0-D7; Thu, 23 Jul 2020 02:51:51 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyRKm-000097-UB for linux-arm-kernel@lists.infradead.org; Thu, 23 Jul 2020 02:51:49 +0000 Received: by mail-qt1-x844.google.com with SMTP id e7so3459142qti.1 for ; Wed, 22 Jul 2020 19:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3FGTIJsMWiuqsdJoUqDQziqKZol4pbNpNal4MX+V3kg=; b=D4Tjc4MSqAmk0rC//KBKh1MiOvF64ETmR5erHLkBNz/8G+d73CGhYZI1//N88xp3ZB PvKfFZuUeECW1tLVijoi3JQv9Up/t+hwwQgH3c8cswSdN6b+/Up9tW7+AtjRsHCmSMCX r4n01aNGXw77bOe/qpolDszh83WgniXUkiV5FRZrDN+31aJwo7pQVXKpIKpw5aIEsGtc Aec8VcRO62DibdZaLmJbPEQHsaxCYOcSRLIzgJUrA1mrdcESDQmhishwfqeMnn4kmy0s /liNR1YE0Fl6tdMi+cbCOMBaisHdmnJ3esEqnEFXLgeP+Ir4bBfTpC1fKWXfgCvzYJdD Sxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3FGTIJsMWiuqsdJoUqDQziqKZol4pbNpNal4MX+V3kg=; b=Y5zapTMYnnm2S8esXrFlcP0xnyrrl9OLydKID+Ooaoo7NsIpnXMetClqRN7aT22h0/ O/pieIMjtAzth1ux0x+bipjRVk9ZHemiL+HqBONsPjhgiVX+lj5Lh+mSQSYXycQBtXZJ nj4UPj+wQSVv43wZnBo6ff3ZGlQZ7HUGjZ4rFL7o636AGLdjyuSdFQeIbDsHULxDBfzT RQHZ9t4gj5CaI/o1uWL/aJvvxdlUgkhdQ5UHwgy57XAb7c7q0teAIRsWRmcmmNzz1eV5 gjGomq+njuoANZinl+lzQDNyVoWkUYIE7TrQh2641oAIsE9zo0eGKX5y7evpstILIvh5 D0OA== X-Gm-Message-State: AOAM530mtc6FhxumVa+hvS65xdzGw9oFuw+2pNxJaHtLEHQzl41JPdLs LDvHOvbmEq746kvdkfNc0oDGc13q X-Google-Smtp-Source: ABdhPJzB3i+6fJCaN7bK3FLHzxEfYv91xyQg7+WuzYFSVlcaYRmb6plJdBFlgj+XI2n9fahxWfbf8A== X-Received: by 2002:ac8:464f:: with SMTP id f15mr2224175qto.211.1595472705344; Wed, 22 Jul 2020 19:51:45 -0700 (PDT) Received: from ubuntu-n2-xlarge-x86 ([2604:1380:45d1:2600::1]) by smtp.gmail.com with ESMTPSA id x13sm1288730qts.57.2020.07.22.19.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 19:51:44 -0700 (PDT) Date: Wed, 22 Jul 2020 19:51:42 -0700 From: Nathan Chancellor To: Marc Zyngier Subject: Re: [PATCH] KVM: arm64: Prevent vcpu_has_ptrauth from generating OOL functions Message-ID: <20200723025142.GA361584@ubuntu-n2-xlarge-x86> References: <20200722162231.3689767-1-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200722162231.3689767-1-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200722_225149_007857_B6DAB42E X-CRM114-Status: GOOD ( 19.77 ) 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: kvm@vger.kernel.org, Suzuki K Poulose , kernel-team@android.com, Nick Desaulniers , James Morse , linux-arm-kernel@lists.infradead.org, Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 22, 2020 at 05:22:31PM +0100, Marc Zyngier wrote: > So far, vcpu_has_ptrauth() is implemented in terms of system_supports_*_auth() > calls, which are declared "inline". In some specific conditions (clang > and SCS), the "inline" very much turns into an "out of line", which > leads to a fireworks when this predicate is evaluated on a non-VHE > system (right at the beginning of __hyp_handle_ptrauth). > > Instead, make sure vcpu_has_ptrauth gets expanded inline by directly > using the cpus_have_final_cap() helpers, which are __always_inline, > generate much better code, and are the only thing that make sense when > running at EL2 on a nVHE system. > > Fixes: 29eb5a3c57f7 ("KVM: arm64: Handle PtrAuth traps early") > Reported-by: Nathan Chancellor > Reported-by: Nick Desaulniers > Signed-off-by: Marc Zyngier Thank you for the quick fix! I have booted a mainline kernel with this patch with Shadow Call Stack enabled and verified that using KVM no longer causes a panic. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor For the future, is there an easy way to tell which type of system I am using (nVHE or VHE)? I am new to the arm64 KVM world but it is something that I am going to continue to test with various clang technologies now that I have actual hardware capable of it that can run a mainline kernel. Cheers, Nathan > --- > arch/arm64/include/asm/kvm_host.h | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 147064314abf..a8278f6873e6 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -391,9 +391,14 @@ struct kvm_vcpu_arch { > #define vcpu_has_sve(vcpu) (system_supports_sve() && \ > ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE)) > > -#define vcpu_has_ptrauth(vcpu) ((system_supports_address_auth() || \ > - system_supports_generic_auth()) && \ > - ((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_PTRAUTH)) > +#ifdef CONFIG_ARM64_PTR_AUTH > +#define vcpu_has_ptrauth(vcpu) \ > + ((cpus_have_final_cap(ARM64_HAS_ADDRESS_AUTH) || \ > + cpus_have_final_cap(ARM64_HAS_GENERIC_AUTH)) && \ > + (vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_PTRAUTH) > +#else > +#define vcpu_has_ptrauth(vcpu) false > +#endif > > #define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs) > > -- > 2.28.0.rc0.142.g3c755180ce-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel