From nobody Sun Nov 24 04:06:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1723624475; cv=none; d=zohomail.com; s=zohoarc; b=Ak/C5m24AZDb2UNlsDLhLvqSvV5B78g6AykKJxd5Onnxy5g7OCLwhZmL2wbmbFNm6YiEH02VQjCvtwny3zFwH2ijqP1ylQu5kfuzbuiOlPikDknrskdH0WbQb2+hS1fP2YeubJZSnXsbplG7XqILCUKuDykM3n1oeXFBcULUBwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723624475; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0p4AvId7LsdumQhFUTANpZvFp9Wi6kOxkHUOGtjN1Vo=; b=Uk+io/3s5Zj2L/IMiUYLcyI2Epql+FTnh1/9PsL9iFnID0uSDbhKXEYX+CUWfmnVBPFUEsmB0hwuh2xjJXsMY8NDPodVItSbGenT32ClYDs50fcWM6OGqAapXyHLA1HPsO86jZ3O/pWhJ6v9xOxeA/mjdAHQgJejDUc5pK3TldQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1723624475878788.1613690791607; Wed, 14 Aug 2024 01:34:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.776833.1187006 (Exim 4.92) (envelope-from ) id 1se9SR-0002tw-NH; Wed, 14 Aug 2024 08:34:15 +0000 Received: by outflank-mailman (output) from mailman id 776833.1187006; Wed, 14 Aug 2024 08:34:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1se9SR-0002tp-KZ; Wed, 14 Aug 2024 08:34:15 +0000 Received: by outflank-mailman (input) for mailman id 776833; Wed, 14 Aug 2024 08:34:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1se9SQ-0002t1-Nk for xen-devel@lists.xenproject.org; Wed, 14 Aug 2024 08:34:14 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fc3a8ba9-5a17-11ef-a505-bb4a2ccca743; Wed, 14 Aug 2024 10:34:13 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5a79df5af51so1103265a12.0 for ; Wed, 14 Aug 2024 01:34:13 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f4183aa5sm145182266b.211.2024.08.14.01.34.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Aug 2024 01:34:12 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: fc3a8ba9-5a17-11ef-a505-bb4a2ccca743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1723624453; x=1724229253; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=0p4AvId7LsdumQhFUTANpZvFp9Wi6kOxkHUOGtjN1Vo=; b=c+eE5GozafZHEnwXB+M6Qys2iFXMju698+NV+r7hUh6Bh3w4H0KdsXGY8TR+Fau+ZA uUH8D4B8GaSj02LCvYbR8eowxHX6Vtb6gG1Zos9FwDsNzLyTwcxHawiXTJ6UivTJ6miG 922bp3x8/c9ZBpQfjeF/1UDdul6OsewZ3XqE8o+yiTXBelk1hlj7eihglf91D437n6E+ XbI/bnOcPdHeUxYArYODw4GJBqefhgl1JLIKAXzC9fio4DRqOgEYKp/BRlHFOuROynP1 nE667yEpa08/hu2TdWliQJZGf2VWbtmg8jEsWKEh26tmOnW3g72BVjPjp/nNI42tZMdA UYrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723624453; x=1724229253; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0p4AvId7LsdumQhFUTANpZvFp9Wi6kOxkHUOGtjN1Vo=; b=kygENiHppVlDeTcOLtDOHGnOQU4gX6uUpRIE01UeJw00coctovt3p0RTZ+orDdAVcJ QYRST3j2ijy8U0jpRou0Gy5wOUDyOKf6S4pkSp0auvlNuzNWlrV0uQN5Jhi/jiTyjLW6 HgDuWWiTEzFFFxefUQAutC6R8MAiYZbwQ8ussvB6unuohdAQA9cztqHHQi2Th9JPziAe mV1z+WbazscchyQK2BO1eIRMsPcV+kg55/Dcj6bT6in9HBTZpTdYOr4j8I62J/zWu1AR fdPQXp+K09dKn74I8qREHkimlAzSbfWaqqZZ8xlCi6VkuwpUG8jUk7F1kk7XJ8ZEM4F2 R0tQ== X-Gm-Message-State: AOJu0YygM8glkHEgyMN7WJ9MzJLtDaTYJ5o58h4Prjg/n46/lqsPXbSj 5B9gkl7uAzKNJ4BRI1AnWz5vZnrAvn5P7Tp50ELW+RZlugn1hJl5lLrNsy8R+lY/4YrMSSCBifU = X-Google-Smtp-Source: AGHT+IHCfMpdstRu/v5hw1srj/M07bk/9QhvLIxwlBwAzcQHH0K5rtJ0DcGPTFre5wHNnCe1FUAzmA== X-Received: by 2002:a17:907:9814:b0:a7d:89ac:9539 with SMTP id a640c23a62f3a-a80f0a77484mr557770966b.7.1723624452906; Wed, 14 Aug 2024 01:34:12 -0700 (PDT) Message-ID: <1512c261-dad4-472d-b6a7-aafd2cb5171b@suse.com> Date: Wed, 14 Aug 2024 10:34:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v5 1/3] x86/CPUID: adjust extended leaves out of range clearing From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <2500a119-1734-44c2-9868-640bcc8ead2d@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7K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C+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <2500a119-1734-44c2-9868-640bcc8ead2d@suse.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1723624476203116600 A maximum extended leaf input value with the high half different from 0x8000 should not be considered valid - all leaves should be cleared in this case. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- TBD: Andrew suggested to drop this patch, but that sub-thread still has a loose end. Hence, until I'm convinced otherwise, I've retained this patch here. I don't think it conflicts with any of the subsequent ones. --- v2: Integrate into series. --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -528,11 +528,22 @@ static void test_cpuid_out_of_range_clea }, }, { + .name =3D "no extd", + .nr_markers =3D 0, + .p =3D { + /* Clears all markers. */ + .extd.max_leaf =3D 0, + + .extd.vendor_ebx =3D 0xc2, + .extd.raw_fms =3D 0xc2, + }, + }, + { .name =3D "extd", .nr_markers =3D 1, .p =3D { /* Retains marker in leaf 0. Clears others. */ - .extd.max_leaf =3D 0, + .extd.max_leaf =3D 0x80000000, .extd.vendor_ebx =3D 0xc2, =20 .extd.raw_fms =3D 0xc2, --- a/xen/lib/x86/cpuid.c +++ b/xen/lib/x86/cpuid.c @@ -285,7 +285,9 @@ void x86_cpu_policy_clear_out_of_range_l ARRAY_SIZE(p->xstate.raw) - 1); } =20 - zero_leaves(p->extd.raw, (p->extd.max_leaf & 0xffff) + 1, + zero_leaves(p->extd.raw, + ((p->extd.max_leaf >> 16) =3D=3D 0x8000 + ? (p->extd.max_leaf & 0xffff) + 1 : 0), ARRAY_SIZE(p->extd.raw) - 1); } =20