Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65A9CC05027 for ; Sat, 18 Feb 2023 00:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjBRA5p (ORCPT ); Fri, 17 Feb 2023 19:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjBRA5n (ORCPT ); Fri, 17 Feb 2023 19:57:43 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C6C35F270 for ; Fri, 17 Feb 2023 16:57:42 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id v10so1525394pgh.0 for ; Fri, 17 Feb 2023 16:57:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0usceKggNKCGc1nrj8ml4jt1oiNoxfaCBZe8A/bFNJE=; b=a3YUzlbPFk6TdZwQ3LJJCtJ9Cg3GMFX2Wu/wOR/8mPXmDZuUH+tPej/7kvCa9/2l+y BEemwWr1jsgvcoxsBcDVl3+p2z0KY3giNpGmvJcVlU3h9IJczoEv1Ijv+r5RAbasuNCI mUzeD149j9+TCqEfjDzU52A69nKfwtJ8Paj9uJW20ghePk+29UdghGXmKkSiOg7g+tIF iO6yxTCT56fADdP2gBorhs9TvtLPy0B/eqzjW6L4xRbcAEXLjWOGnenqcKaPqvu0z5FJ uj/DQdIdU8fwSR/mnq3v2kZSl/nZjMUgPZf4nJ0qlVKMjXNTsUVNaxfDpiR9n2wY+8iA Ei3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0usceKggNKCGc1nrj8ml4jt1oiNoxfaCBZe8A/bFNJE=; b=f7LiIUqDD30jlhW1hMHUBFov5DocK4OFFP7DB99p6NuwOojLugqiokk/IR4lr8W4Ld CTlFI2NWsgZ8s/TKXNpLALC/+fGvX3q15m7OtVq9Lx8HNMGW5YSxuNEZ9DWYSv+0n0tq gZXh7gqrUJ/KNTXZa8nY9KbJ/eJymLoiN4+9BMjdqmUo8dt/DaHvR+qEXDCLju+L7PQZ bYFy6qIfmi5gAbQuwsYKnTHEPF8ypBip2yC34Z+xpB4c+aZGYSooVP+g5ENqYXeHPfog HWXUzr37z3MWbBPchsm8IW33SNCxXDci4ef69h+v1jqpbUyJOkgd2N2T9NXX426d9DDr 0ZcA== X-Gm-Message-State: AO0yUKUuBKk1dXtTI5iUcplbBcePqd00TCDmH9QtNJwAoyhQ6/5UfawI s37hLU8qT6jvu5pjWl07tR0ofA== X-Google-Smtp-Source: AK7set/LXZrK5+seQgidJp1G/DYMPwiRrF7zemmtKS2OaKJrTRzgkApTRwKGRRfLGDWD9/z3fxrNFQ== X-Received: by 2002:a05:6a00:4305:b0:5a8:51a3:7f69 with SMTP id cb5-20020a056a00430500b005a851a37f69mr6923585pfb.2.1676681861601; Fri, 17 Feb 2023 16:57:41 -0800 (PST) Received: from google.com (77.62.105.34.bc.googleusercontent.com. [34.105.62.77]) by smtp.gmail.com with ESMTPSA id g23-20020aa78757000000b005a8beb26794sm3602449pfo.132.2023.02.17.16.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 16:57:41 -0800 (PST) Date: Sat, 18 Feb 2023 00:57:37 +0000 From: Mingwei Zhang To: Aaron Lewis Cc: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson , Venkatesh Srinivas , "Chang S. Bae" Subject: Re: [PATCH v2 3/7] KVM: selftests: x86: Add check of CR0.TS in the #NM handler in amx_test Message-ID: References: <20230214184606.510551-1-mizhang@google.com> <20230214184606.510551-4-mizhang@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 17, 2023, Aaron Lewis wrote: > On Tue, Feb 14, 2023 at 6:46 PM Mingwei Zhang wrote: > > > > Add check of CR0.TS[bit 3] before the check of IA32_XFD_ERR in the #NM > > handler in amx_test. This is because XFD may not be the only reason of > > the IA32_XFD MSR and the bitmap corresponding to the state components > > required by the faulting instruction." (Intel SDM vol 1. Section 13.14) > > > > Add the missing check of CR0.TS. > > > > Signed-off-by: Mingwei Zhang > > --- > > tools/testing/selftests/kvm/x86_64/amx_test.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c > > index aac727ff7cf8..847752998660 100644 > > --- a/tools/testing/selftests/kvm/x86_64/amx_test.c > > +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c > > @@ -215,6 +215,7 @@ void guest_nm_handler(struct ex_regs *regs) > > { > > /* Check if #NM is triggered by XFEATURE_MASK_XTILEDATA */ > > GUEST_SYNC(7); > > + GUEST_ASSERT((get_cr0() & X86_CR0_TS) == 0); > > Can't we infer that the #NM is the result of an XFD error due to the fact > that IA32_XFD_ERR is set? Is this check needed? > SDM vol 1, 13.14, EXTENDED FEATURE DISABLE (XFD) > - Device-not-available exceptions that are not due to XFD - those > resulting from setting CR0.TS to 1 - do not modify the IA32_XFD_ERR > MSR. > We don't infer from the reasons of #NM and that is the purpose of this selftest. Yes, this looks a little bit pedantic. But still, it is worth adding the check since violation of that indicates either 1) the selftest mistakenly did not clear XFD_ERR prior to #NM or 2) hardware is broken. > > GUEST_ASSERT(rdmsr(MSR_IA32_XFD_ERR) == XFEATURE_MASK_XTILEDATA); > > GUEST_SYNC(8); > > GUEST_ASSERT(rdmsr(MSR_IA32_XFD_ERR) == XFEATURE_MASK_XTILEDATA); > > -- > > 2.39.1.581.gbfd45094c4-goog > >