From patchwork Mon Mar 5 20:18:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10259649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 67F8260365 for ; Mon, 5 Mar 2018 20:18:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 568C228A78 for ; Mon, 5 Mar 2018 20:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B61928AE6; Mon, 5 Mar 2018 20:18:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C92CB28A78 for ; Mon, 5 Mar 2018 20:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752543AbeCEUSq (ORCPT ); Mon, 5 Mar 2018 15:18:46 -0500 Received: from mail-bn3nam01on0062.outbound.protection.outlook.com ([104.47.33.62]:47061 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751723AbeCEUSn (ORCPT ); Mon, 5 Mar 2018 15:18:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Yk0C7447rjAZe0OqXl/HwJzvbNoYOapE3J+QPurlSYQ=; b=kfAkaspAi/OPoJmbGxRVqz5G5HtlTgMzL0vq94h+lQrFY/fzVN0222qbPaAnhr89J1H+U5kKO+oXzXEe0DthK/Ofe1XAmOACesE74+/wZyCJCfJjviOHcHqu2ZClUI+bbW8L1LFzInkUJFCNYEVHoNNrlYbWWsQGz8jBBr9JDN4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-pyp0.amd.com (165.204.77.1) by BN6PR12MB1763.namprd12.prod.outlook.com (10.175.101.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Mon, 5 Mar 2018 20:18:39 +0000 From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, rkrcmar@redhat.com Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, Gary.Hook@amd.com, Thomas.Lendacky@amd.com, babu.moger@amd.com Subject: [PATCH v3 1/5] target/i386: Generalize some of the macro definitions Date: Mon, 5 Mar 2018 15:18:23 -0500 Message-Id: <1520281107-5115-2-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520281107-5115-1-git-send-email-babu.moger@amd.com> References: <1520281107-5115-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR1801CA0014.namprd18.prod.outlook.com (10.171.252.27) To BN6PR12MB1763.namprd12.prod.outlook.com (10.175.101.136) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ccab2049-0bf8-44cd-17aa-08d582d648f8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:BN6PR12MB1763; X-Microsoft-Exchange-Diagnostics: 1; BN6P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t5E2hgnUEVDkbGxhjJRANJl0s0dPONjI6EJdR4+KSjOJLJCJ5WaQn5JWKZp+P+wi4hjnAUvm4rqh7Z+ReEnZx+6su4Az1EGPIpYqyymxqhosgoBNUqHzU45gP61EO2FaO3FTenMCKwHT1uvM53SstJaw970AQWlHn7ODMQBeCNoIFjKHbcDi1IaTYGNHnG+Z0UgwqCgH4cgPXq+GuCoeKLsjqesWH33XCNVXwSYTHGPAL4gcluE+V+0INhgih4cWq+m9PWOYx+U5UztUrcfrJYHJBe+cGvlarTEUisex44zqaTpK2fM8bb18SE6yyBhG+Rha6A62Hy1sR/pLbWPeQkWEM9; 4:jSSL2vUzj47baZRSnc8JzzFbmDu0aS1Dqeg5Oakz5emOhpNOelBDDoQ3jD3mYbTLKHlyr4YanHyvtup41i5OmTwfLhHzhMMbi/ag2gFkBsaLc+WiSFta0sQ0IIbe4C6jA9hhNP4+eZyMStnhNdVO1ty3kL5owseADTdCsiugaheM09Mh01V8YLoiLhJiq2mJR4q5E4MPUdnGJ3gtuFDm0aHOYGo7D2JmjVl0FwupVAg1Nn09YAPJ0IIqIZhGelItvS/+pO5VKIq77sihJEYV/398SF/04kGxVfvwE+4SsO49cMPI6Ps7BpwrS5ebHUYH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3231220)(944501244)(52105095)(3002001)(93006095)(93001095)(6055026)(6041288)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:BN6PR12MB1763; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1763; X-Forefront-PRVS: 06022AA85F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(366004)(376002)(346002)(189003)(199004)(2950100002)(4720700003)(2906002)(106356001)(66066001)(6666003)(97736004)(25786009)(36756003)(5660300001)(478600001)(48376002)(81166006)(81156014)(8676002)(72206003)(47776003)(8936002)(50226002)(4326008)(105586002)(50466002)(26005)(6486002)(305945005)(16586007)(186003)(16526019)(316002)(52116002)(53936002)(7696005)(68736007)(53416004)(3846002)(6116002)(386003)(51416003)(7736002)(76176011)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1763; H:linux-pyp0.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1763; 23:iKoFNoOoDTMjJ9EXQFe+TOoqATCPt08EXK1iV/gzw?= =?us-ascii?Q?poCCIpbmWvhwZ/uKVkt2XYqSAmyx+0bMmdL4aEEIn8rQqaSDxlYCSXI1HWYs?= =?us-ascii?Q?oYa97uMsbrVhXwuzHcf6FYM/zNe0PfBhXff3Qn4TfR/rQXc3tmEgtOO0f8ey?= =?us-ascii?Q?CbFAAaePeux5tvDbe9FMV97ONvXA9wa5dxnW18NUd42weKpZiPmG/DMLs52z?= =?us-ascii?Q?qZk/sjGQZf6ToFX0uDzo0Gaz8uKoDl+9RHjMIP/VQuRy9w86jz3giGaGceXh?= =?us-ascii?Q?dj8K0aLi56Uczu/n9W0qiMQ3StY//l7cW6B8Bkb2FV+A6+g0yJiy7HWyqGyF?= =?us-ascii?Q?q9M+vWws/JUlvklDSG26VloIJ8Q5Va7x2soihEsTSc8W6X6Asi+YjZNiL0bI?= =?us-ascii?Q?WfW4W1rhKa+fFWdE+LyYUI3SdeB4lAZbN6nv8wJTBKZ629cv3zKWW03V1TCi?= =?us-ascii?Q?Lo71jEvBU8/kEntuQs4OXkUUHryx2pWVurudNRX7LiaLZ00FBbk6Wj00AvMs?= =?us-ascii?Q?eFpv6yJv7gcIaDC/g81lUqRbUitu3+I941qu5a/KllHGRTapzdIB3RiDtj/i?= =?us-ascii?Q?9ZlWxorTYJ/Wbb6MsmR7rD43ummh+8OvylTltKrPCl6soEU2Gxhb0evbkDgl?= =?us-ascii?Q?9JFrTgeONn5utUO/WB9a8k2kX6Pv/S0erPPjdqq32bxOKnYfTrN5FE8bmkkb?= =?us-ascii?Q?hpyL4jap7VBgqt4BCkBNi/MSfqHN989AZrciBRLGkibWSerKXdZ8tO8vWZos?= =?us-ascii?Q?LIWj+I+b/ynw7AwJjeF7spn11L5U8lLQmup4DtXKepVRtS32KI235m659R6n?= =?us-ascii?Q?XXaA0/19PBCcMQBDdy8J/1CDi7LTbpYgrtexhAZepRteTIUuCobvDYSsmUHx?= =?us-ascii?Q?nUYKv6VpKfyI0qjBkq3DI7CI4AIE3VlMo7+6gPJ02eX1ql4+bO77Cb3EqlVP?= =?us-ascii?Q?yRd6tG05gvIHtGph55t+cGqZRpIbriTIUptZaFIVYh25sYJAvxMwhrU5Mtci?= =?us-ascii?Q?ypIciFyKCU+rS6S/m+EKKCblrZT3YDx7R6f7Eb69tX1Z17TcUigfuuPgtWY9?= =?us-ascii?Q?gD129emkfpr/H7+6J6Wuw6njjAcnGKpCnEAjxUW1QObsfNmkvHJYA9t3MT7A?= =?us-ascii?Q?D+Nu2ucCS899hxavUIcofW320NHdKFa?= X-Microsoft-Antispam-Message-Info: tp98g34feYlcLrLgDybcTEr7Rb6seTc7mp1wlX+3Y0i78rzqGk/fe+xIewCHn8pYK82QycXza4Lw4iwfaGVTI0dUz7futzmtcAEJF5RqJdh36nzWSwfszo0hcOJ75hvc23Yt7F8ET1sWWGCPkywdEnmb05sYobKa9gCqIFZOrys/tbKZV4ei9cHNCKxXc7CP X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1763; 6:ndJfQWJQ/jY30Mnhaowpf5SS8tB2ImL4iuA0bKWZXe2W1MhOrhYB7OXQp5dvWYwwEk89+vhRPQwXICRKaQbanMbi01oREsz7pTszfapDfPq6691EpHjbKHDMLuKaCci2J+0+2bvKPQo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K/tPExigHjb8G1oVezEqHw/2EjE3Ib4JMEleC4UEP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2018 20:18:39.0842 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccab2049-0bf8-44cd-17aa-08d582d648f8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1763 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Generalize some of the macro definitions which are generic cache properties that are common between CPUID 4 and CPUID 0x8000001D in preparation for adding support for 0x8000001D. Signed-off-by: Babu Moger --- target/i386/cpu.c | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b5e431e..42dd381 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -66,22 +66,22 @@ #define CPUID_2_L3_16MB_16WAY_64B 0x4d -/* CPUID Leaf 4 constants: */ +/* Cache specific constants: */ /* EAX: */ -#define CPUID_4_TYPE_DCACHE 1 -#define CPUID_4_TYPE_ICACHE 2 -#define CPUID_4_TYPE_UNIFIED 3 +#define TYPE_DCACHE 1 +#define TYPE_ICACHE 2 +#define TYPE_UNIFIED 3 -#define CPUID_4_LEVEL(l) ((l) << 5) +#define CACHE_LEVEL(l) ((l) << 5) -#define CPUID_4_SELF_INIT_LEVEL (1 << 8) -#define CPUID_4_FULLY_ASSOC (1 << 9) +#define CACHE_SELF_INIT_LEVEL (1 << 8) +#define CACHE_FULLY_ASSOC (1 << 9) /* EDX: */ -#define CPUID_4_NO_INVD_SHARING (1 << 0) -#define CPUID_4_INCLUSIVE (1 << 1) -#define CPUID_4_COMPLEX_IDX (1 << 2) +#define CACHE_NO_INVD_SHARING (1 << 0) +#define CACHE_INCLUSIVE (1 << 1) +#define CACHE_COMPLEX_IDX (1 << 2) #define ASSOC_FULL 0xFF @@ -3273,29 +3273,29 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *eax = 0; switch (count) { case 0: /* L1 dcache info */ - *eax |= CPUID_4_TYPE_DCACHE | \ - CPUID_4_LEVEL(1) | \ - CPUID_4_SELF_INIT_LEVEL; + *eax |= TYPE_DCACHE | \ + CACHE_LEVEL(1) | \ + CACHE_SELF_INIT_LEVEL; *ebx = (L1D_LINE_SIZE - 1) | \ ((L1D_PARTITIONS - 1) << 12) | \ ((L1D_ASSOCIATIVITY - 1) << 22); *ecx = L1D_SETS - 1; - *edx = CPUID_4_NO_INVD_SHARING; + *edx = CACHE_NO_INVD_SHARING; break; case 1: /* L1 icache info */ - *eax |= CPUID_4_TYPE_ICACHE | \ - CPUID_4_LEVEL(1) | \ - CPUID_4_SELF_INIT_LEVEL; + *eax |= TYPE_ICACHE | \ + CACHE_LEVEL(1) | \ + CACHE_SELF_INIT_LEVEL; *ebx = (L1I_LINE_SIZE - 1) | \ ((L1I_PARTITIONS - 1) << 12) | \ ((L1I_ASSOCIATIVITY - 1) << 22); *ecx = L1I_SETS - 1; - *edx = CPUID_4_NO_INVD_SHARING; + *edx = CACHE_NO_INVD_SHARING; break; case 2: /* L2 cache info */ - *eax |= CPUID_4_TYPE_UNIFIED | \ - CPUID_4_LEVEL(2) | \ - CPUID_4_SELF_INIT_LEVEL; + *eax |= TYPE_UNIFIED | \ + CACHE_LEVEL(2) | \ + CACHE_SELF_INIT_LEVEL; if (cs->nr_threads > 1) { *eax |= (cs->nr_threads - 1) << 14; } @@ -3303,7 +3303,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, ((L2_PARTITIONS - 1) << 12) | \ ((L2_ASSOCIATIVITY - 1) << 22); *ecx = L2_SETS - 1; - *edx = CPUID_4_NO_INVD_SHARING; + *edx = CACHE_NO_INVD_SHARING; break; case 3: /* L3 cache info */ if (!cpu->enable_l3_cache) { @@ -3313,16 +3313,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = 0; break; } - *eax |= CPUID_4_TYPE_UNIFIED | \ - CPUID_4_LEVEL(3) | \ - CPUID_4_SELF_INIT_LEVEL; + *eax |= TYPE_UNIFIED | \ + CACHE_LEVEL(3) | \ + CACHE_SELF_INIT_LEVEL; pkg_offset = apicid_pkg_offset(cs->nr_cores, cs->nr_threads); *eax |= ((1 << pkg_offset) - 1) << 14; *ebx = (L3_N_LINE_SIZE - 1) | \ ((L3_N_PARTITIONS - 1) << 12) | \ ((L3_N_ASSOCIATIVITY - 1) << 22); *ecx = L3_N_SETS - 1; - *edx = CPUID_4_INCLUSIVE | CPUID_4_COMPLEX_IDX; + *edx = CACHE_INCLUSIVE | CACHE_COMPLEX_IDX; break; default: /* end of info */ *eax = 0;