From nobody Thu Jan 8 14:47:31 2026 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; 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=1766422438; cv=none; d=zohomail.com; s=zohoarc; b=hn+HgLhaSHIXb/5yW4OJtJYvuGZPDLZZo/5QLKaB8oWt0drniV9UvEZk9f4umwFQbOwKkfrE5QAcgUi9woDQiOE/w/OIz65EBodikrrQ5joMPqvZdALja+KJasVF/79vtYsnxpNuszzZG7ttUD03qvYCMY7DoASfFQS3jvaJoec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766422438; 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=OsI4gloEQwSNKupVpgjb2Rjg/GFGEQhJx0eZpnb+0kY=; b=Pr14GktZTeVp20SALgOXYyl7fvWC7g4Aao7EORDTOfuuPNm6XFxy2mxyfzT4AdZJqARcRiZqg10g5LgliWBeoWhIx245X9p4+Y5RW3X0cbegmcZHv8gU1tS02MMN3g1jCmNjTuKpXzPEu16hAUJL1X7XCgHpHFA8bSqn7NKLVus= 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 1766422438517148.385152838203; Mon, 22 Dec 2025 08:53:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1192297.1511599 (Exim 4.92) (envelope-from ) id 1vXjAB-0001Dl-4G; Mon, 22 Dec 2025 16:53:39 +0000 Received: by outflank-mailman (output) from mailman id 1192297.1511599; Mon, 22 Dec 2025 16:53:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vXjAB-0001De-1T; Mon, 22 Dec 2025 16:53:39 +0000 Received: by outflank-mailman (input) for mailman id 1192297; Mon, 22 Dec 2025 16:53:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vXjA9-000115-Vf for xen-devel@lists.xenproject.org; Mon, 22 Dec 2025 16:53:37 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c1bd1f42-df56-11f0-9cce-f158ae23cfc8; Mon, 22 Dec 2025 17:53:36 +0100 (CET) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-47774d3536dso32831145e9.0 for ; Mon, 22 Dec 2025 08:53:36 -0800 (PST) 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 5b1f17b1804b1-47be26a81b6sm256333345e9.0.2025.12.22.08.53.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Dec 2025 08:53:35 -0800 (PST) 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: c1bd1f42-df56-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1766422415; x=1767027215; 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=OsI4gloEQwSNKupVpgjb2Rjg/GFGEQhJx0eZpnb+0kY=; b=Kvj0gE52rfDUjh5Q08Y4to8rdew5zYeR98U/RzVKLz0ZB5Jn8ikPbd8D7enn6a6Sbt 284QOLcRibV+U96uzWUUrMhTZYXrL0nFcxO+F8Yr7l0fMPWH8hVeNEJ4LuSSHpqO17J9 yLbqjBI5tuJqHkMHe5bCSusc4c4Mp/BCYZeTWPpPT4kjYhvQjJeDQa7rTg4chwy8TLp0 hFejHo0F+LoSHMWKfWouYa7bAqAJA3zXnXxGGEz1b00KlSXxE1sPHqfmLIqbge9VKA62 08nKLQhHTaKnCsJOurmDnW7AzBPfDtO+2Mie0JdnEXsKKaUdpeiD+JNdilofNFetBEdZ C2ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766422415; x=1767027215; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OsI4gloEQwSNKupVpgjb2Rjg/GFGEQhJx0eZpnb+0kY=; b=lvzAQXdJrLbboN46I6DZXf8mHN4vloqgX1e/nLk+UiVjDOwJJZz//B94g19yhxzFwy TScICS/ZpVptTkXkTX0H/KO1XIU1A45R8PNteimairMO/vaiaOwGwEYlzjN7wah9WFMN MqQ6XY4KnyeVGxs0z58yuiyx/eWnMjdmXo7NHI95cW4yOIgFAIXLPIhzAFSoTBqBbyCT 8xUf6NhyEHzQUfuAm2JcaKgoib+WNaKxzewQJhFJQkYQg3xGcJ81coXEUBWBgsoMDGb8 gEBrupIOiM2Zieoa8IXBcFbcgoV8Sj3icyvkIABEcz3260nxPYLmui5Jc5E3GVt6Fonw VVmw== X-Gm-Message-State: AOJu0Yw/yZDVq5mbFD59k0xKQsDKJn5NOZrkDMCpgRZTfcZ1wWVAj/0d 3mOx5v/YHBf3hema4azy1F2VrWbua/MQnf5ED0hVfq021WoEQqWNZf42aS1M2Bc1zhz5HqPCz4T 21xg= X-Gm-Gg: AY/fxX5oaQMhmjOOvQ3CssXX3bI2qBTcJjjebugdmQHgJ88FugK/5nvJ2oI4Vq5IjJ3 +Z79KMTfD4OvVWSP8TqForF2Dh+vgdxIp5RkWBcFD/XeWoaQFlGyEd8OBNMVu/nAgP7sqHhLTAN L1tAw7SS0hWPXcfJ3/Zbs4FlYGIITMxs2/GNH80x1Ccu0CDWrpDl7z0jzGcr3Qh5aazapiqOmYm Cmv5m29ScCjGBm7v213mSwXzux4YcVzeSTvC7fcSlpOfnmgFdAD9RpU9Cf4hdfClzHMDB0JalSR i7ytWX3o4Gf51OpJ8tBU3h/DAVmxZIuDkxDNZg5Su2pe7ZxhNGjKxZhYkRTk2AQG1QADoeSpXeF 17pP4EHa3BL/7ZCOmE1XG7RM7ZH2h6APNDii07L1h5bqNZZ7GYjJF0SL0UvewoeaB5zg7mxs6OA wvO9ElgtWeGTzw/61ysb3N7Dh6mjCtpOM0M3iISNer2WTHelCZNkgs4az1snvDCgr44G/PdVYFe w0= X-Google-Smtp-Source: AGHT+IF2lC4cnqGNcq2rVKk1AV+Bn5JYXNhVRLxThywUFL+h8Cas2G9mfgXMxfXU/ehzBirTEr+WXw== X-Received: by 2002:a05:600c:8b11:b0:479:13e9:3d64 with SMTP id 5b1f17b1804b1-47d2d273999mr45505925e9.15.1766422415444; Mon, 22 Dec 2025 08:53:35 -0800 (PST) Message-ID: Date: Mon, 22 Dec 2025 17:53:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] x86/cpu-policy: enable build of fuzzing harness by default From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD References: <4a8f06b9-8210-487f-9dd7-e0221e2df9db@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <4a8f06b9-8210-487f-9dd7-e0221e2df9db@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1766422440405158500 Content-Type: text/plain; charset="utf-8" ... on x86, to make sure its bit-rotting can be limited at least a little. Signed-off-by: Jan Beulich --- a/tools/fuzz/Makefile +++ b/tools/fuzz/Makefile @@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk SUBDIRS-y :=3D SUBDIRS-y +=3D libelf SUBDIRS-y +=3D x86_instruction_emulator +SUBDIRS-$(CONFIG_X86_64) +=3D cpu-policy =20 .PHONY: all clean distclean install uninstall all clean distclean install uninstall: %: subdirs-% From nobody Thu Jan 8 14:47:31 2026 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; 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=1766422516; cv=none; d=zohomail.com; s=zohoarc; b=aet+YchI7WTYLgHnGe2MkTrrkqcu4104de/5zNnxDJRg/VNn17HrwqFj0h+p3hQPhEPB7LwfKUh3H6PCKDvmil0LH/DC2pwV0XuZhQ+DFgpOOy0JcqlWQkbzijmRMnBSUQFnQwL/wWtrJHzhjvfrxbXj+VD2+S0jeccjYcH+6no= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766422516; 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=h4UevlDelbU9Pq4j3DueOab96zFdtjsssm1G7f69TuQ=; b=Ue5KwZglhCfe5W9FBGv2Kdqt72AIt/EIgZjhrC9QhU29uYitjRM+ZPvowYKLUFivd3K5jSXBUuGUvRiOzlnQAUKhw4shKI1cgnB6Pbcn0lQ57lr5Zs5x2ZaBXJebe4mOIH6SI42WHxJqCvJ9t+lNxjYXnVfYQG8JlM9yYxXUuag= 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 1766422516631237.56232431117076; Mon, 22 Dec 2025 08:55:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1192307.1511611 (Exim 4.92) (envelope-from ) id 1vXjBT-0001l0-FW; Mon, 22 Dec 2025 16:54:59 +0000 Received: by outflank-mailman (output) from mailman id 1192307.1511611; Mon, 22 Dec 2025 16:54:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vXjBT-0001kt-Ay; Mon, 22 Dec 2025 16:54:59 +0000 Received: by outflank-mailman (input) for mailman id 1192307; Mon, 22 Dec 2025 16:54:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vXjBR-0001kn-GL for xen-devel@lists.xenproject.org; Mon, 22 Dec 2025 16:54:57 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f0bf4e4b-df56-11f0-9cce-f158ae23cfc8; Mon, 22 Dec 2025 17:54:54 +0100 (CET) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-42fbc305882so2148189f8f.0 for ; Mon, 22 Dec 2025 08:54:54 -0800 (PST) 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 ffacd0b85a97d-4324ea226d1sm23513860f8f.13.2025.12.22.08.54.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Dec 2025 08:54:53 -0800 (PST) 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: f0bf4e4b-df56-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1766422494; x=1767027294; 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=h4UevlDelbU9Pq4j3DueOab96zFdtjsssm1G7f69TuQ=; b=MXr8hTFbnyAHUj0lWW9Mugb1B6ap9CrbxJpHGCJ3uITgCrWoBbRhFoDd5txNIaFy+g Z14Vis6O6ZYERC6vW7tERnH9XqeYVXJFBGDAn8GXvjkPZBYpKxJJWj6rQlDen071UgoI 38i6XMft6mTyCIh5KSOa11S4dygXfWGyPLmFBLOXl36NDtvjsT5g8cRU1uA9Wn9Llfbw J72eLZjNAyHgG8m9pQs+CG1rJZm3iv0TFdxwCwYHbLPIw4XCsNUTy6HhOldsoNncK3xj HQLDO+olodEGDrHyvSjQ0KDUtTGn/nyC/WL8tQpjnCIKr+veTqBVQaYCWFheeJL1gLZD V7Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766422494; x=1767027294; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h4UevlDelbU9Pq4j3DueOab96zFdtjsssm1G7f69TuQ=; b=HjRu5eoaKm721ej96VCHPz0sa6S+G7EPrBdOv9z559bXEAieoZ0jfKRGfGJV9HAXz9 uG7cPze43i1b3YI9OJ45HXBNtksJ1+qgmlamaJr63Mrguu6ikuj1S1Jia5RUuKOvuORE J9ah7PMo7fkLSRmuHY2d8cGIuot9TvKjYEa7aqYZBNE6cxEqzTC8xABSgN/5CKAhVyYQ 5LYn8tXI529UKCy2NuM2jQ73vQbQlpS8pRnNU93/8HJFnMLPqxhbfCwOoNW2WeLZ2oKK y1R+3igexQ7AHXxbbpoLrPTCFcOi/YeE4R9UpyD4TIxG2AQErGK77fDv7mFsud5Na8k7 UWcA== X-Gm-Message-State: AOJu0Yz60sSnv7Ra66G+VBHwknjKKCP9e9MIdU09ajzTkdaJDru8IhwH zip5OplLzpG3GImtIlAl2Q+KEGhJbOYpUY+/ba6y7uClMW6+ZKWk9ITW/bQ4TgSa/6SC2IqkRnW cc60= X-Gm-Gg: AY/fxX6Q2I+1syH+G1ghKVKsAf+1Oeczxa2X/6Z5/LJnBp1Nw3k9Iy0GcPLpsSzzSpE fuvV2sVy9538zrAvFa7qUQHdm1r3UDr8PPMYwEcJa/9oLzIlX2YRywJHPhAunpDrDWxkNG8duXH 6PVg6KmLD6vxzgMUJ+u7dpHMyvrfYdw8U0DES5omLvG1b9bSodHbt6kNEqIsrrEiMq9IYH2zT1w DlqgmGaNCOTM82f02UBWdvwl2GFVv2V1A4t1yqWYxGl3cWgsUMTRjvYeAgMRvMoeRRU2Cg/N5J9 Bewichnea3ciFxT6aWPpLw4h2ykAIylBXeesY/6tZ7jwDUEJOLLveggiSMQhv/r0ooq9UQK21R0 XoHUrUVBTV5+qDfpItoeHaiDTuVuO+ZLhr+w2b+pc1WAmXc8TAAtyONOf5ctcp7cGECWtS8Gxf2 PTJvotFhbkMbUynYt93v9uaG8BfWMKBKe/UqkEZM5Xl3EeRDuCdVq/Iwi5clhFgzJ6jKalDrsVp ndswaL4G842jg== X-Google-Smtp-Source: AGHT+IGGNEP8R51YHcTVHI1J6n+HvViMPPWJH2k75K40fzbLspg0wnvCN9EU2Ya7lHhnmdHW0OX6Wg== X-Received: by 2002:a5d:5d11:0:b0:430:f68f:ee91 with SMTP id ffacd0b85a97d-4324e4f68f5mr14055522f8f.37.1766422494158; Mon, 22 Dec 2025 08:54:54 -0800 (PST) Message-ID: <41447fdb-bc9a-4b1a-afd0-9d878ab21301@suse.com> Date: Mon, 22 Dec 2025 17:54:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] x86/cpu-policy: move copy-in/-out functions to arch library From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Penny Zheng , Anthony PERARD References: <4a8f06b9-8210-487f-9dd7-e0221e2df9db@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <4a8f06b9-8210-487f-9dd7-e0221e2df9db@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1766422518468158500 Content-Type: text/plain; charset="utf-8" This is to aid with MGMT_HYPERCALL work, leaving the functions potentially unreferenced (which Misra dislikes). By moving them to separate archive members, the linker simply will not pick them up when not needed. As the CPUID and MSR ones are always used together, put the "from" and "to" variants of each together in one file respectively. Signed-off-by: Jan Beulich --- a/tools/fuzz/cpu-policy/Makefile +++ b/tools/fuzz/cpu-policy/Makefile @@ -20,9 +20,13 @@ install: all CFLAGS +=3D $(CFLAGS_xeninclude) -D__XEN_TOOLS__ CFLAGS +=3D $(APPEND_CFLAGS) -Og =20 -vpath %.c ../../../xen/lib/x86 +vpath %.c $(XEN_ROOT)/xen/lib/x86 +vpath %.c $(XEN_ROOT)/xen/arch/x86/lib =20 -afl-policy-fuzzer: afl-policy-fuzzer.o msr.o cpuid.o +lib-y :=3D +include $(XEN_ROOT)/xen/arch/x86/lib/Makefile.cpu-policy + +afl-policy-fuzzer: afl-policy-fuzzer.o cpuid.o $(lib-y) $(CC) $(CFLAGS) $^ -o $@ =20 -include $(DEPS_INCLUDE) --- a/tools/libs/guest/Makefile.common +++ b/tools/libs/guest/Makefile.common @@ -33,9 +33,13 @@ LIBELF_OBJS +=3D libelf-dominfo.o OBJS-y +=3D $(LIBELF_OBJS) =20 ifeq ($(CONFIG_X86),y) # Add libx86 to the build -vpath %.c ../../../xen/lib/x86 +vpath %.c $(XEN_ROOT)/xen/lib/x86 +vpath %.c $(XEN_ROOT)/xen/arch/x86/lib =20 -OBJS-y +=3D cpuid.o msr.o policy.o +lib-y :=3D +include $(XEN_ROOT)/xen/arch/x86/lib/Makefile.cpu-policy + +OBJS-y +=3D cpuid.o policy.o $(lib-y) endif =20 # new domain builder --- a/tools/tests/cpu-policy/Makefile +++ b/tools/tests/cpu-policy/Makefile @@ -42,11 +42,15 @@ CFLAGS +=3D $(APPEND_CFLAGS) =20 LDFLAGS +=3D $(APPEND_LDFLAGS) =20 -vpath %.c ../../../xen/lib/x86 +vpath %.c $(XEN_ROOT)/xen/lib/x86 +vpath %.c $(XEN_ROOT)/xen/arch/x86/lib + +lib-y :=3D +include $(XEN_ROOT)/xen/arch/x86/lib/Makefile.cpu-policy =20 %.o: Makefile =20 -test-cpu-policy: test-cpu-policy.o msr.o cpuid.o policy.o +test-cpu-policy: test-cpu-policy.o cpuid.o policy.o $(lib-y) $(CC) $^ -o $@ $(LDFLAGS) =20 -include $(DEPS_INCLUDE) --- a/xen/arch/x86/lib/Makefile +++ b/xen/arch/x86/lib/Makefile @@ -6,3 +6,5 @@ lib-y +=3D generic-hweightl.o lib-y +=3D memcpy.o lib-y +=3D memset.o lib-y +=3D scrub-page.o + +include $(srcdir)/Makefile.cpu-policy --- /dev/null +++ b/xen/arch/x86/lib/Makefile.cpu-policy @@ -0,0 +1,2 @@ +lib-y +=3D cp-copy-from-buffer.o +lib-y +=3D cp-copy-to-buffer.o --- /dev/null +++ b/xen/arch/x86/lib/cp-copy-from-buffer.c @@ -0,0 +1,238 @@ +#ifdef __XEN__ + +#include +#include +#include +#include + +#include + +#define copy_from_buffer_offset copy_from_guest_offset + +#else /* !__XEN__ */ + +#include +#include +#include +#include +#include + +#include + +#include + +#define array_access_nospec(a, i) (a)[(i)] + +/* memcpy(), but with copy_from_guest_offset()'s API. */ +#define copy_from_buffer_offset(dst, src, index, nr) \ +({ \ + const typeof(*(src)) *src_ =3D (src); \ + typeof(*(dst)) *dst_ =3D (dst); \ + typeof(index) index_ =3D (index); \ + typeof(nr) nr_ =3D (nr), i_; \ + \ + for ( i_ =3D 0; i_ < nr_; i_++ ) \ + dst_[i_] =3D src_[index_ + i_]; \ + 0; \ +}) + +#endif /* __XEN__ */ + +#include + +int x86_cpuid_copy_from_buffer(struct cpu_policy *p, + const cpuid_leaf_buffer_t leaves, + uint32_t nr_entries, uint32_t *err_leaf, + uint32_t *err_subleaf) +{ + unsigned int i; + xen_cpuid_leaf_t data; + + if ( err_leaf ) + *err_leaf =3D -1; + if ( err_subleaf ) + *err_subleaf =3D -1; + + /* + * A well formed caller is expected to pass an array with leaves in or= der, + * and without any repetitions. However, due to per-vendor difference= s, + * and in the case of upgrade or levelled scenarios, we typically expe= ct + * fewer than MAX leaves to be passed. + * + * Detecting repeated entries is prohibitively complicated, so we don't + * bother. That said, one way or another if more than MAX leaves are + * passed, something is wrong. + */ + if ( nr_entries > CPUID_MAX_SERIALISED_LEAVES ) + return -E2BIG; + + for ( i =3D 0; i < nr_entries; ++i ) + { + struct cpuid_leaf l; + + if ( copy_from_buffer_offset(&data, leaves, i, 1) ) + return -EFAULT; + + l =3D (struct cpuid_leaf){ data.a, data.b, data.c, data.d }; + + switch ( data.leaf ) + { + case 0 ... ARRAY_SIZE(p->basic.raw) - 1: + switch ( data.leaf ) + { + case 0x4: + if ( data.subleaf >=3D ARRAY_SIZE(p->cache.raw) ) + goto out_of_range; + + array_access_nospec(p->cache.raw, data.subleaf) =3D l; + break; + + case 0x7: + if ( data.subleaf >=3D ARRAY_SIZE(p->feat.raw) ) + goto out_of_range; + + array_access_nospec(p->feat.raw, data.subleaf) =3D l; + break; + + case 0xb: + if ( data.subleaf >=3D ARRAY_SIZE(p->topo.raw) ) + goto out_of_range; + + array_access_nospec(p->topo.raw, data.subleaf) =3D l; + break; + + case 0xd: + if ( data.subleaf >=3D ARRAY_SIZE(p->xstate.raw) ) + goto out_of_range; + + array_access_nospec(p->xstate.raw, data.subleaf) =3D l; + break; + + default: + if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) + goto out_of_range; + + array_access_nospec(p->basic.raw, data.leaf) =3D l; + break; + } + break; + + case 0x40000000: + if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) + goto out_of_range; + + p->hv_limit =3D l.a; + break; + + case 0x40000100: + if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) + goto out_of_range; + + p->hv2_limit =3D l.a; + break; + + case 0x80000000U ... 0x80000000U + ARRAY_SIZE(p->extd.raw) - 1: + if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) + goto out_of_range; + + array_access_nospec(p->extd.raw, data.leaf & 0xffff) =3D l; + break; + + default: + goto out_of_range; + } + } + + x86_cpu_policy_recalc_synth(p); + + return 0; + + out_of_range: + if ( err_leaf ) + *err_leaf =3D data.leaf; + if ( err_subleaf ) + *err_subleaf =3D data.subleaf; + + return -ERANGE; +} + +int x86_msr_copy_from_buffer(struct cpu_policy *p, + const msr_entry_buffer_t msrs, uint32_t nr_en= tries, + uint32_t *err_msr) +{ + unsigned int i; + xen_msr_entry_t data; + int rc; + + if ( err_msr ) + *err_msr =3D -1; + + /* + * A well formed caller is expected to pass an array with entries in + * order, and without any repetitions. However, due to per-vendor + * differences, and in the case of upgrade or levelled scenarios, we + * typically expect fewer than MAX entries to be passed. + * + * Detecting repeated entries is prohibitively complicated, so we don't + * bother. That said, one way or another if more than MAX entries are + * passed, something is wrong. + */ + if ( nr_entries > MSR_MAX_SERIALISED_ENTRIES ) + return -E2BIG; + + for ( i =3D 0; i < nr_entries; i++ ) + { + if ( copy_from_buffer_offset(&data, msrs, i, 1) ) + return -EFAULT; + + if ( data.flags ) /* .flags MBZ */ + { + rc =3D -EINVAL; + goto err; + } + + switch ( data.idx ) + { + /* + * Assign data.val to p->field, checking for truncation if the + * backing storage for field is smaller than uint64_t + */ +#define ASSIGN(field) \ +({ \ + if ( (typeof(p->field))data.val !=3D data.val ) \ + { \ + rc =3D -EOVERFLOW; \ + goto err; \ + } \ + p->field =3D data.val; \ +}) + + case MSR_INTEL_PLATFORM_INFO: ASSIGN(platform_info.raw); break; + case MSR_ARCH_CAPABILITIES: ASSIGN(arch_caps.raw); break; + +#undef ASSIGN + + default: + rc =3D -ERANGE; + goto err; + } + } + + return 0; + + err: + if ( err_msr ) + *err_msr =3D data.idx; + + return rc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- /dev/null +++ b/xen/arch/x86/lib/cp-copy-to-buffer.c @@ -0,0 +1,204 @@ +#ifdef __XEN__ + +#include +#include +#include + +#include + +#define copy_to_buffer_offset copy_to_guest_offset + +#else /* !__XEN__ */ + +#include +#include +#include +#include +#include + +#include + +#include + +/* memcpy(), but with copy_to_guest_offset()'s API. */ +#define copy_to_buffer_offset(dst, index, src, nr) \ +({ \ + const typeof(*(src)) *src_ =3D (src); \ + typeof(*(dst)) *dst_ =3D (dst); \ + typeof(index) index_ =3D (index); \ + typeof(nr) nr_ =3D (nr), i_; \ + \ + for ( i_ =3D 0; i_ < nr_; i_++ ) \ + dst_[index_ + i_] =3D src_[i_]; \ + 0; \ +}) + +#endif /* __XEN__ */ + +#include + +/* + * Copy a single cpuid_leaf into a provided xen_cpuid_leaf_t buffer, + * performing boundary checking against the buffer size. + */ +static int copy_leaf_to_buffer(uint32_t leaf, uint32_t subleaf, + const struct cpuid_leaf *data, + cpuid_leaf_buffer_t leaves, + uint32_t *curr_entry, const uint32_t nr_ent= ries) +{ + const xen_cpuid_leaf_t val =3D { + leaf, subleaf, data->a, data->b, data->c, data->d, + }; + + if ( *curr_entry =3D=3D nr_entries ) + return -ENOBUFS; + + if ( copy_to_buffer_offset(leaves, *curr_entry, &val, 1) ) + return -EFAULT; + + ++*curr_entry; + + return 0; +} + +int x86_cpuid_copy_to_buffer(const struct cpu_policy *p, + cpuid_leaf_buffer_t leaves, uint32_t *nr_entr= ies_p) +{ + const uint32_t nr_entries =3D *nr_entries_p; + uint32_t curr_entry =3D 0, leaf, subleaf; + +#define COPY_LEAF(l, s, data) \ + ({ \ + int ret; \ + \ + if ( (ret =3D copy_leaf_to_buffer( \ + l, s, data, leaves, &curr_entry, nr_entries)) ) \ + return ret; \ + }) + + /* Basic leaves. */ + for ( leaf =3D 0; leaf <=3D MIN(p->basic.max_leaf, + ARRAY_SIZE(p->basic.raw) - 1); ++leaf ) + { + switch ( leaf ) + { + case 0x4: + for ( subleaf =3D 0; subleaf < ARRAY_SIZE(p->cache.raw); ++sub= leaf ) + { + COPY_LEAF(leaf, subleaf, &p->cache.raw[subleaf]); + + if ( p->cache.subleaf[subleaf].type =3D=3D 0 ) + break; + } + break; + + case 0x7: + for ( subleaf =3D 0; + subleaf <=3D MIN(p->feat.max_subleaf, + ARRAY_SIZE(p->feat.raw) - 1); ++subleaf ) + COPY_LEAF(leaf, subleaf, &p->feat.raw[subleaf]); + break; + + case 0xb: + for ( subleaf =3D 0; subleaf < ARRAY_SIZE(p->topo.raw); ++subl= eaf ) + { + COPY_LEAF(leaf, subleaf, &p->topo.raw[subleaf]); + + if ( p->topo.subleaf[subleaf].type =3D=3D 0 ) + break; + } + break; + + case 0xd: + { + uint64_t xstates =3D cpu_policy_xstates(p); + + COPY_LEAF(leaf, 0, &p->xstate.raw[0]); + COPY_LEAF(leaf, 1, &p->xstate.raw[1]); + + for ( xstates >>=3D 2, subleaf =3D 2; + xstates && subleaf < ARRAY_SIZE(p->xstate.raw); + xstates >>=3D 1, ++subleaf ) + COPY_LEAF(leaf, subleaf, &p->xstate.raw[subleaf]); + break; + } + + default: + COPY_LEAF(leaf, XEN_CPUID_NO_SUBLEAF, &p->basic.raw[leaf]); + break; + } + } + + /* TODO: Port Xen and Viridian leaves to the new CPUID infrastructure.= */ + COPY_LEAF(0x40000000, XEN_CPUID_NO_SUBLEAF, + &(struct cpuid_leaf){ p->hv_limit }); + COPY_LEAF(0x40000100, XEN_CPUID_NO_SUBLEAF, + &(struct cpuid_leaf){ p->hv2_limit }); + + /* Extended leaves. */ + for ( leaf =3D 0; leaf <=3D MIN(p->extd.max_leaf & 0xffffUL, + ARRAY_SIZE(p->extd.raw) - 1); ++leaf ) + COPY_LEAF(0x80000000U | leaf, XEN_CPUID_NO_SUBLEAF, &p->extd.raw[l= eaf]); + +#undef COPY_LEAF + + *nr_entries_p =3D curr_entry; + + return 0; +} + +/* + * Copy a single MSR into the provided msr_entry_buffer_t buffer, performi= ng a + * boundary check against the buffer size. + */ +static int copy_msr_to_buffer(uint32_t idx, uint64_t val, + msr_entry_buffer_t msrs, + uint32_t *curr_entry, const uint32_t nr_entr= ies) +{ + const xen_msr_entry_t ent =3D { .idx =3D idx, .val =3D val }; + + if ( *curr_entry =3D=3D nr_entries ) + return -ENOBUFS; + + if ( copy_to_buffer_offset(msrs, *curr_entry, &ent, 1) ) + return -EFAULT; + + ++*curr_entry; + + return 0; +} + +int x86_msr_copy_to_buffer(const struct cpu_policy *p, + msr_entry_buffer_t msrs, uint32_t *nr_entries_p) +{ + const uint32_t nr_entries =3D *nr_entries_p; + uint32_t curr_entry =3D 0; + +#define COPY_MSR(idx, val) \ + ({ \ + int ret; \ + \ + if ( (ret =3D copy_msr_to_buffer( \ + idx, val, msrs, &curr_entry, nr_entries)) ) \ + return ret; \ + }) + + COPY_MSR(MSR_INTEL_PLATFORM_INFO, p->platform_info.raw); + COPY_MSR(MSR_ARCH_CAPABILITIES, p->arch_caps.raw); + +#undef COPY_MSR + + *nr_entries_p =3D curr_entry; + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/lib/x86/Makefile +++ b/xen/lib/x86/Makefile @@ -1,3 +1,2 @@ obj-y +=3D cpuid.o -obj-y +=3D msr.o obj-y +=3D policy.o --- a/xen/lib/x86/cpuid.c +++ b/xen/lib/x86/cpuid.c @@ -323,232 +323,6 @@ const uint32_t *x86_cpu_policy_lookup_de } =20 /* - * Copy a single cpuid_leaf into a provided xen_cpuid_leaf_t buffer, - * performing boundary checking against the buffer size. - */ -static int copy_leaf_to_buffer(uint32_t leaf, uint32_t subleaf, - const struct cpuid_leaf *data, - cpuid_leaf_buffer_t leaves, - uint32_t *curr_entry, const uint32_t nr_ent= ries) -{ - const xen_cpuid_leaf_t val =3D { - leaf, subleaf, data->a, data->b, data->c, data->d, - }; - - if ( *curr_entry =3D=3D nr_entries ) - return -ENOBUFS; - - if ( copy_to_buffer_offset(leaves, *curr_entry, &val, 1) ) - return -EFAULT; - - ++*curr_entry; - - return 0; -} - -int x86_cpuid_copy_to_buffer(const struct cpu_policy *p, - cpuid_leaf_buffer_t leaves, uint32_t *nr_entr= ies_p) -{ - const uint32_t nr_entries =3D *nr_entries_p; - uint32_t curr_entry =3D 0, leaf, subleaf; - -#define COPY_LEAF(l, s, data) \ - ({ \ - int ret; \ - \ - if ( (ret =3D copy_leaf_to_buffer( \ - l, s, data, leaves, &curr_entry, nr_entries)) ) \ - return ret; \ - }) - - /* Basic leaves. */ - for ( leaf =3D 0; leaf <=3D MIN(p->basic.max_leaf, - ARRAY_SIZE(p->basic.raw) - 1); ++leaf ) - { - switch ( leaf ) - { - case 0x4: - for ( subleaf =3D 0; subleaf < ARRAY_SIZE(p->cache.raw); ++sub= leaf ) - { - COPY_LEAF(leaf, subleaf, &p->cache.raw[subleaf]); - - if ( p->cache.subleaf[subleaf].type =3D=3D 0 ) - break; - } - break; - - case 0x7: - for ( subleaf =3D 0; - subleaf <=3D MIN(p->feat.max_subleaf, - ARRAY_SIZE(p->feat.raw) - 1); ++subleaf ) - COPY_LEAF(leaf, subleaf, &p->feat.raw[subleaf]); - break; - - case 0xb: - for ( subleaf =3D 0; subleaf < ARRAY_SIZE(p->topo.raw); ++subl= eaf ) - { - COPY_LEAF(leaf, subleaf, &p->topo.raw[subleaf]); - - if ( p->topo.subleaf[subleaf].type =3D=3D 0 ) - break; - } - break; - - case 0xd: - { - uint64_t xstates =3D cpu_policy_xstates(p); - - COPY_LEAF(leaf, 0, &p->xstate.raw[0]); - COPY_LEAF(leaf, 1, &p->xstate.raw[1]); - - for ( xstates >>=3D 2, subleaf =3D 2; - xstates && subleaf < ARRAY_SIZE(p->xstate.raw); - xstates >>=3D 1, ++subleaf ) - COPY_LEAF(leaf, subleaf, &p->xstate.raw[subleaf]); - break; - } - - default: - COPY_LEAF(leaf, XEN_CPUID_NO_SUBLEAF, &p->basic.raw[leaf]); - break; - } - } - - /* TODO: Port Xen and Viridian leaves to the new CPUID infrastructure.= */ - COPY_LEAF(0x40000000, XEN_CPUID_NO_SUBLEAF, - &(struct cpuid_leaf){ p->hv_limit }); - COPY_LEAF(0x40000100, XEN_CPUID_NO_SUBLEAF, - &(struct cpuid_leaf){ p->hv2_limit }); - - /* Extended leaves. */ - for ( leaf =3D 0; leaf <=3D MIN(p->extd.max_leaf & 0xffffUL, - ARRAY_SIZE(p->extd.raw) - 1); ++leaf ) - COPY_LEAF(0x80000000U | leaf, XEN_CPUID_NO_SUBLEAF, &p->extd.raw[l= eaf]); - -#undef COPY_LEAF - - *nr_entries_p =3D curr_entry; - - return 0; -} - -int x86_cpuid_copy_from_buffer(struct cpu_policy *p, - const cpuid_leaf_buffer_t leaves, - uint32_t nr_entries, uint32_t *err_leaf, - uint32_t *err_subleaf) -{ - unsigned int i; - xen_cpuid_leaf_t data; - - if ( err_leaf ) - *err_leaf =3D -1; - if ( err_subleaf ) - *err_subleaf =3D -1; - - /* - * A well formed caller is expected to pass an array with leaves in or= der, - * and without any repetitions. However, due to per-vendor difference= s, - * and in the case of upgrade or levelled scenarios, we typically expe= ct - * fewer than MAX leaves to be passed. - * - * Detecting repeated entries is prohibitively complicated, so we don't - * bother. That said, one way or another if more than MAX leaves are - * passed, something is wrong. - */ - if ( nr_entries > CPUID_MAX_SERIALISED_LEAVES ) - return -E2BIG; - - for ( i =3D 0; i < nr_entries; ++i ) - { - struct cpuid_leaf l; - - if ( copy_from_buffer_offset(&data, leaves, i, 1) ) - return -EFAULT; - - l =3D (struct cpuid_leaf){ data.a, data.b, data.c, data.d }; - - switch ( data.leaf ) - { - case 0 ... ARRAY_SIZE(p->basic.raw) - 1: - switch ( data.leaf ) - { - case 0x4: - if ( data.subleaf >=3D ARRAY_SIZE(p->cache.raw) ) - goto out_of_range; - - array_access_nospec(p->cache.raw, data.subleaf) =3D l; - break; - - case 0x7: - if ( data.subleaf >=3D ARRAY_SIZE(p->feat.raw) ) - goto out_of_range; - - array_access_nospec(p->feat.raw, data.subleaf) =3D l; - break; - - case 0xb: - if ( data.subleaf >=3D ARRAY_SIZE(p->topo.raw) ) - goto out_of_range; - - array_access_nospec(p->topo.raw, data.subleaf) =3D l; - break; - - case 0xd: - if ( data.subleaf >=3D ARRAY_SIZE(p->xstate.raw) ) - goto out_of_range; - - array_access_nospec(p->xstate.raw, data.subleaf) =3D l; - break; - - default: - if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) - goto out_of_range; - - array_access_nospec(p->basic.raw, data.leaf) =3D l; - break; - } - break; - - case 0x40000000: - if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) - goto out_of_range; - - p->hv_limit =3D l.a; - break; - - case 0x40000100: - if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) - goto out_of_range; - - p->hv2_limit =3D l.a; - break; - - case 0x80000000U ... 0x80000000U + ARRAY_SIZE(p->extd.raw) - 1: - if ( data.subleaf !=3D XEN_CPUID_NO_SUBLEAF ) - goto out_of_range; - - array_access_nospec(p->extd.raw, data.leaf & 0xffff) =3D l; - break; - - default: - goto out_of_range; - } - } - - x86_cpu_policy_recalc_synth(p); - - return 0; - - out_of_range: - if ( err_leaf ) - *err_leaf =3D data.leaf; - if ( err_subleaf ) - *err_subleaf =3D data.subleaf; - - return -ERANGE; -} - -/* * Local variables: * mode: C * c-file-style: "BSD" --- a/xen/lib/x86/msr.c +++ /dev/null @@ -1,130 +0,0 @@ -#include "private.h" - -#include - -/* - * Copy a single MSR into the provided msr_entry_buffer_t buffer, performi= ng a - * boundary check against the buffer size. - */ -static int copy_msr_to_buffer(uint32_t idx, uint64_t val, - msr_entry_buffer_t msrs, - uint32_t *curr_entry, const uint32_t nr_entr= ies) -{ - const xen_msr_entry_t ent =3D { .idx =3D idx, .val =3D val }; - - if ( *curr_entry =3D=3D nr_entries ) - return -ENOBUFS; - - if ( copy_to_buffer_offset(msrs, *curr_entry, &ent, 1) ) - return -EFAULT; - - ++*curr_entry; - - return 0; -} - -int x86_msr_copy_to_buffer(const struct cpu_policy *p, - msr_entry_buffer_t msrs, uint32_t *nr_entries_p) -{ - const uint32_t nr_entries =3D *nr_entries_p; - uint32_t curr_entry =3D 0; - -#define COPY_MSR(idx, val) \ - ({ \ - int ret; \ - \ - if ( (ret =3D copy_msr_to_buffer( \ - idx, val, msrs, &curr_entry, nr_entries)) ) \ - return ret; \ - }) - - COPY_MSR(MSR_INTEL_PLATFORM_INFO, p->platform_info.raw); - COPY_MSR(MSR_ARCH_CAPABILITIES, p->arch_caps.raw); - -#undef COPY_MSR - - *nr_entries_p =3D curr_entry; - - return 0; -} - -int x86_msr_copy_from_buffer(struct cpu_policy *p, - const msr_entry_buffer_t msrs, uint32_t nr_en= tries, - uint32_t *err_msr) -{ - unsigned int i; - xen_msr_entry_t data; - int rc; - - if ( err_msr ) - *err_msr =3D -1; - - /* - * A well formed caller is expected to pass an array with entries in - * order, and without any repetitions. However, due to per-vendor - * differences, and in the case of upgrade or levelled scenarios, we - * typically expect fewer than MAX entries to be passed. - * - * Detecting repeated entries is prohibitively complicated, so we don't - * bother. That said, one way or another if more than MAX entries are - * passed, something is wrong. - */ - if ( nr_entries > MSR_MAX_SERIALISED_ENTRIES ) - return -E2BIG; - - for ( i =3D 0; i < nr_entries; i++ ) - { - if ( copy_from_buffer_offset(&data, msrs, i, 1) ) - return -EFAULT; - - if ( data.flags ) /* .flags MBZ */ - { - rc =3D -EINVAL; - goto err; - } - - switch ( data.idx ) - { - /* - * Assign data.val to p->field, checking for truncation if the - * backing storage for field is smaller than uint64_t - */ -#define ASSIGN(field) \ -({ \ - if ( (typeof(p->field))data.val !=3D data.val ) \ - { \ - rc =3D -EOVERFLOW; \ - goto err; \ - } \ - p->field =3D data.val; \ -}) - - case MSR_INTEL_PLATFORM_INFO: ASSIGN(platform_info.raw); break; - case MSR_ARCH_CAPABILITIES: ASSIGN(arch_caps.raw); break; - -#undef ASSIGN - - default: - rc =3D -ERANGE; - goto err; - } - } - - return 0; - - err: - if ( err_msr ) - *err_msr =3D data.idx; - - return rc; -} - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ --- a/xen/lib/x86/private.h +++ b/xen/lib/x86/private.h @@ -12,9 +12,6 @@ =20 #include =20 -#define copy_to_buffer_offset copy_to_guest_offset -#define copy_from_buffer_offset copy_from_guest_offset - #else =20 #include @@ -35,34 +32,6 @@ static inline bool test_bit(unsigned int return addr[bit / 8] & (1u << (bit % 8)); } =20 -#define array_access_nospec(a, i) (a)[(i)] - -/* memcpy(), but with copy_to_guest_offset()'s API. */ -#define copy_to_buffer_offset(dst, index, src, nr) \ -({ \ - const typeof(*(src)) *src_ =3D (src); \ - typeof(*(dst)) *dst_ =3D (dst); \ - typeof(index) index_ =3D (index); \ - typeof(nr) nr_ =3D (nr), i_; \ - \ - for ( i_ =3D 0; i_ < nr_; i_++ ) \ - dst_[index_ + i_] =3D src_[i_]; \ - 0; \ -}) - -/* memcpy(), but with copy_from_guest_offset()'s API. */ -#define copy_from_buffer_offset(dst, src, index, nr) \ -({ \ - const typeof(*(src)) *src_ =3D (src); \ - typeof(*(dst)) *dst_ =3D (dst); \ - typeof(index) index_ =3D (index); \ - typeof(nr) nr_ =3D (nr), i_; \ - \ - for ( i_ =3D 0; i_ < nr_; i_++ ) \ - dst_[i_] =3D src_[index_ + i_]; \ - 0; \ -}) - #endif /* __XEN__ */ =20 #endif /* XEN_LIB_X86_PRIVATE_H */