From patchwork Mon Jun 7 12:41:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12303481 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=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 B2854C47082 for ; Mon, 7 Jun 2021 12:41:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 73AAF61078 for ; Mon, 7 Jun 2021 12:41:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73AAF61078 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.137911.255417 (Exim 4.92) (envelope-from ) id 1lqEZM-00082w-K6; Mon, 07 Jun 2021 12:41:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 137911.255417; Mon, 07 Jun 2021 12:41:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqEZM-00082p-Fr; Mon, 07 Jun 2021 12:41:28 +0000 Received: by outflank-mailman (input) for mailman id 137911; Mon, 07 Jun 2021 12:41:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqEZL-00082j-Bv for xen-devel@lists.xenproject.org; Mon, 07 Jun 2021 12:41:27 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fb71e5c2-4264-4af1-a06d-f5e1b5f5b3ba; Mon, 07 Jun 2021 12:41:25 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fb71e5c2-4264-4af1-a06d-f5e1b5f5b3ba DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1623069684; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=e21/IGcWymo5MIqD1rnrm7qEJJUELfd/4foTt5tkdmY=; b=eXYPe5ZLS29F1kqJwUL41WIGflAx3bIY2WsUkECCGOX5xI24ukiKDgfY tRlHCLlA7IhxFiPI3ud4LdMk18XN8lkJdbLyQkccWtTkONQ1dTr+bcWk/ qcs3EJ9yy6OAejwna+ya5HJwPpjPMdqK7X6hJWN6iaLTjiKg1Wu7E96yU Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: fiVjXspTC+it6lcBUkjP2Oto3/hNkUH99pmvJs7QBmN9c3U0HLGyIMxwSVGXnQKf39T6r2RRCE uK/WCtExn2HTB9t8rfyS7m/Ni86TSMH1FuNjbj7tOoEtbTGA+31YIJ03CknguXtMN5PL5NK4JU TgvAxOQudR3x103kWk4oaDiTygLToZ+aWzxBIduxlGYiqzqRdHhZNr7ToNnPVPrtxNb92BbRYk mlZvbtRSwZN00ZwhTg4Z5zY1eYfRfXYwbP9svncVLjSuWo+Fh4CHv+l2BXCSGqfkIA42T35Mjn UdU= X-SBRS: 5.1 X-MesageID: 45278750 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:pjRvOqA++2VDlGnlHemL55DYdb4zR+YMi2TDtnoBKiC9Hfb0qy nDppsmPHzP6Ar5OktLpTnoAsDpfZq7z/BICOEqVotKNzOLhILHFuBfxLqn7gSlPhbT2YdmpM VdWpk7JdHrD2FAq4LQ/Am8Hr8bsb262ZHtqOvFzU5Xa0VPZ7t75wl0MQqVe3cGITV7OQ== X-IronPort-AV: E=Sophos;i="5.83,255,1616472000"; d="scan'208";a="45278750" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH] x86/cpuid: Fix HLE and RTM handling (again) Date: Mon, 7 Jun 2021 13:41:16 +0100 Message-ID: <20210607124116.24250-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 For reasons which are my fault, but I don't recall why, the FDP_EXCP_ONLY/NO_FPU_SEL adjustment uses the whole special_features[] array, not the two relevant bits. HLE and RTM were recently added to the list of special features, causing them to be always set in guest view, irrespective of the toolstacks choice on the matter. Rewrite the logic to refer to the features specifically, rather than relying on the contents of the special_features[] array. Fixes: 8fe24090d9 ("x86/cpuid: Rework HLE and RTM handling") Signed-off-by: Andrew Cooper Reported-by: Edwin Török Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu --- xen/arch/x86/cpuid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index f3c8950aa3..958caf35da 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -672,9 +672,11 @@ void recalculate_cpuid_policy(struct domain *d) sanitise_featureset(fs); /* Fold host's FDP_EXCP_ONLY and NO_FPU_SEL into guest's view. */ - fs[FEATURESET_7b0] &= ~special_features[FEATURESET_7b0]; + fs[FEATURESET_7b0] &= ~(cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) | + cpufeat_mask(X86_FEATURE_NO_FPU_SEL)); fs[FEATURESET_7b0] |= (host_cpuid_policy.feat._7b0 & - special_features[FEATURESET_7b0]); + (cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) | + cpufeat_mask(X86_FEATURE_NO_FPU_SEL))); cpuid_featureset_to_policy(fs, p);