From patchwork Tue May 22 00:41:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10417157 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 69C926032C for ; Tue, 22 May 2018 00:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A3D728AF9 for ; Tue, 22 May 2018 00:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E23728AFF; Tue, 22 May 2018 00:41:38 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, 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 A5C4C28AF9 for ; Tue, 22 May 2018 00:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbeEVAlg (ORCPT ); Mon, 21 May 2018 20:41:36 -0400 Received: from mail-co1nam03on0042.outbound.protection.outlook.com ([104.47.40.42]:64128 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751745AbeEVAlb (ORCPT ); Mon, 21 May 2018 20:41:31 -0400 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:X-MS-Exchange-SenderADCheck; bh=ytmnL1GxcRFT0Uf9aNyQ539CGs50H8hSS2TKZouQsf0=; b=BKMxmQfYg2gqPwCkAdGEzQU9ktHhLcdCGCQ+DGE63Wo4ezNeuuyFw4dOo2ciPdg/b+5jM9jmGqC08AxV7Yo/8DGugWYjHfdSjWWo9o+aUHGGj/ZMnTPA8Tmn1RbaveR3XtXci6GzwmjrqG6Py0KUAq8btdM40cdwkvhSfw08Iwk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-h3ml.amd.com (165.204.77.1) by SN1PR12MB2479.namprd12.prod.outlook.com (2603:10b6:802:29::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Tue, 22 May 2018 00:41:24 +0000 From: Babu Moger To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, babu.moger@amd.com, kash@tripleback.net, geoff@hostfission.com Subject: [PATCH v10 2/5] i386: Populate AMD Processor Cache Information for cpuid 0x8000001D Date: Mon, 21 May 2018 20:41:12 -0400 Message-Id: <1526949675-106737-3-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1526949675-106737-1-git-send-email-babu.moger@amd.com> References: <1526949675-106737-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR12CA0071.namprd12.prod.outlook.com (2603:10b6:802:20::42) To SN1PR12MB2479.namprd12.prod.outlook.com (2603:10b6:802:29::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:SN1PR12MB2479; X-Microsoft-Exchange-Diagnostics: 1; SN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VjJgTFSKGJxUvu23zSJId55DSSAc87kw74VQWkx+GQZc+oD7gLgAQV2YeoMXEZgJcvGOWsekOzFKCAsN8G1yfl4okZCuMneu+iwdjiYTjw4AYhsKMcDgSm4s2QM4YtLaQlqwQ3+yQc14OZj+WAToCmO8UZYh5/WqVJBooU3qNnuxI2cu++2Ks3iEhjZQCx73O4takxtdO+e2Pi7F30opJ9CxgBU9H/+TxH5Pm12ZK8Cg0SOjiMkYGzN7LsFyO9NspMu1Dmp+2BCxdTgIegbTAezJWbnbWH+UMjzj4TYWq69t8qnm1KdrfZj48A6AK1L+SP/k/sSFLTnxTFZixmxHUdP3OHGY98dcS/K/SbuNNgYdJLNkq; 4:7u8pvgwo+AM4prwtkWF3PMPn805XSKOxRTciD56M21A6dt2bHRAQVoBtRTJwwmnJZPRMKu7ArB51UQWVvdf95I9ejiMXNb8nIBK2Jv6V/VyrJYAhqQXQSKelOkDjG0xYv4DIZfN5v0qif+KNS8shDxxh6o0dknKiJwNWnBKLLa72OzP4Z8U2ArKWeVt5EpW/DMfrUWnrq2e3Q+eoW8amiz851TziWQqTTXbAc5uscjlOE5X7oqZVtwzqwxVpMVFo/n4q4ewXiliDRzlI38tCsZenUcfM1luDYrgg86C/sqa+Lu50bjAfktMMfUB1VyQ1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:SN1PR12MB2479; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2479; X-Forefront-PRVS: 0680FADD48 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(39860400002)(376002)(39380400002)(199004)(189003)(66066001)(25786009)(6666003)(36756003)(316002)(305945005)(2616005)(486006)(3846002)(4720700003)(68736007)(956004)(47776003)(7736002)(53936002)(44832011)(50466002)(2906002)(6116002)(446003)(476003)(11346002)(8676002)(26005)(81166006)(8936002)(106356001)(7416002)(81156014)(386003)(105586002)(86362001)(97736004)(72206003)(5660300001)(478600001)(7696005)(186003)(23676004)(39060400002)(50226002)(53416004)(6486002)(16526019)(52116002)(76176011)(4326008)(2870700001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2479; H:linux-h3ml.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjEyTUIyNDc5OzIzOitEUnZwZGpLd1BISHlqbWloUU04a05wQlov?= =?utf-8?B?aW9PRFluYmFmOVY3ZEtWZEZLQXYwSFJjOUV4N1l1cWVqRDhqZTY3b0gxK25r?= =?utf-8?B?WURQSzYvOTN5NnBxajVIMlRCRnpPd2pzVDVpek05eVJuR0k4Zk02NTU3L3pU?= =?utf-8?B?czBsUmpObWl0L21aV2ZsNkJrYUg2SWxKYm1Xa2NEYWlacWhGQ2dpUU10ZFU0?= =?utf-8?B?azd6L21OOVkydVIvbHJSUmVWMFUrVzJ6UU50SytOZm9GNG5QWjZaZUVHcHFj?= =?utf-8?B?eU5kbm5rZ04zYm53WEZZbFlKNzMrSWw3d3BBM1VBZStsT25sb2gyQzQ5K0hk?= =?utf-8?B?OEZPOGw1UmVkZHU1b0xkaFFRSTE3bDArU1dFUFN6VjVlNTlyWWtuMkpsOUNR?= =?utf-8?B?UmtkbjdlckNWOTBVNUdrSGRZNTEyek1DbmF3STZvRTQ5M1pqVHJaZFpEWUs0?= =?utf-8?B?aDl1VWNScy9oLzFYcmh0WXJhYUNadHhKeFRDTDcwbjUzTVJD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umVJL2Bsx5yZL99+Pu60SQwTMR8usS2oq3YFw==; 5:HGMS+pSrCqOP44oIwRaP9aZVteR2bn65C3LSDfuM3U14ZGV2ns4Dz2Zjrrrvpsc/ppgI4Cjc+ry3XqfLLCH+eZx/1KliId1aX//3LrVobDkt1uXBGdR17e4jR8Y8XaRtjyBt7Hzqqv895HvO5x65m9alk5N0kqx7CUDILIltELg=; 24:ngkHA9O+koi8tp9h+BMyRz4Zx+Cb8IupGxKMTwlpXvAYs8VfmrQ/rcSFv34PfJhCbwG+4aVMv0jJPoqc3lJLUWGmCe9kLj8EWS3Ha1IpP2o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2479; 7:vm9//Z34FeIDkqVADPBb7OQ1tlLUsjDEvRg0XjeGqPOURoPmEbGBsJRfGn5OT9rzpKr8p1KSYGDeCchRVGgEyT0e6JcKuZkb15cIlrz9moWJohDZPkE3cZLB2cF0u+mLnlBjGzXuI/P7Ig2iDis5w1vrgpvlPOorFu/5NlbxRbvpJZyMXxbp4A4Ym3fEdz9ngPiPARZsGiCLo8tE7F/4G25oIrpQl7iy1vLVclr5IiAhpNftG6en6qzeZQqZRz3y; 20:xMCREo81KrUsbc1CrfYX0v8Hr60g097ndhT7TtfwbCiMWCkOVaTtGihXmk24VeOmlWOM9N2GhWnSyvMuu6E+6ukSG1a7hzznZfneDjNT2GAj6su66KIid4PciFtB4Muq2brIqzWyVknUtaWL4xsxIL8h5ieMccaoaZ5GOjvPh09L8M8D1narWvrpTlHTiIKyKY7PHdn2B2eJebTIOZVP7Tzmf/3frfoben/sSyKjxr8dSnlGI2DsKiTtBM+OuJNB X-MS-Office365-Filtering-Correlation-Id: 07647035-9108-4cf4-8bd8-08d5bf7cbf97 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2018 00:41:24.6366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07647035-9108-4cf4-8bd8-08d5bf7cbf97 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2479 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add information for cpuid 0x8000001D leaf. Populate cache topology information for different cache types(Data Cache, Instruction Cache, L2 and L3) supported by 0x8000001D leaf. Please refer Processor Programming Reference (PPR) for AMD Family 17h Model for more details. Signed-off-by: Babu Moger --- target/i386/cpu.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ target/i386/kvm.c | 29 +++++++++++++-- 2 files changed, 129 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d9773b6..1dd060a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -336,6 +336,85 @@ static void encode_cache_cpuid80000006(CPUCacheInfo *l2, } } +/* Definitions used for building CPUID Leaf 0x8000001D and 0x8000001E */ +/* Please refer AMD64 Architecture Programmer’s Manual Volume 3 */ +#define MAX_CCX 2 +#define MAX_CORES_IN_CCX 4 +#define MAX_NODES_EPYC 4 +#define MAX_CORES_IN_NODE 8 + +/* Number of logical processors sharing L3 cache */ +#define NUM_SHARING_CACHE(threads, num_sharing) ((threads > 1) ? \ + (((num_sharing - 1) * threads) + 1) : \ + (num_sharing - 1)) +/* + * L3 Cache is shared between all the cores in a core complex. + * Maximum cores that can share L3 is 4. + */ +static int num_sharing_l3_cache(int nr_cores) +{ + int i, nodes = 1; + + /* Check if we can fit all the cores in one CCX */ + if (nr_cores <= MAX_CORES_IN_CCX) { + return nr_cores; + } + /* + * Figure out the number of nodes(or dies) required to build + * this config. Max cores in a node is 8 + */ + for (i = nodes; i <= MAX_NODES_EPYC; i++) { + if (nr_cores <= (i * MAX_CORES_IN_NODE)) { + nodes = i; + break; + } + /* We support nodes 1, 2, 4 */ + if (i == 3) { + continue; + } + } + /* Spread the cores accros all the CCXs and return max cores in a ccx */ + return (nr_cores / (nodes * MAX_CCX)) + + ((nr_cores % (nodes * MAX_CCX)) ? 1 : 0); +} + +/* Encode cache info for CPUID[8000001D] */ +static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) +{ + uint32_t num_share_l3; + assert(cache->size == cache->line_size * cache->associativity * + cache->partitions * cache->sets); + + *eax = CACHE_TYPE(cache->type) | CACHE_LEVEL(cache->level) | + (cache->self_init ? CACHE_SELF_INIT_LEVEL : 0); + + /* L3 is shared among multiple cores */ + if (cache->level == 3) { + num_share_l3 = num_sharing_l3_cache(cs->nr_cores); + *eax |= (NUM_SHARING_CACHE(cs->nr_threads, num_share_l3) << 14); + } else { + *eax |= ((cs->nr_threads - 1) << 14); + } + + assert(cache->line_size > 0); + assert(cache->partitions > 0); + assert(cache->associativity > 0); + /* We don't implement fully-associative caches */ + assert(cache->associativity < cache->sets); + *ebx = (cache->line_size - 1) | + ((cache->partitions - 1) << 12) | + ((cache->associativity - 1) << 22); + + assert(cache->sets > 0); + *ecx = cache->sets - 1; + + *edx = (cache->no_invd_sharing ? CACHE_NO_INVD_SHARING : 0) | + (cache->inclusive ? CACHE_INCLUSIVE : 0) | + (cache->complex_indexing ? CACHE_COMPLEX_IDX : 0); +} + /* * Definitions of the hardcoded cache entries we expose: * These are legacy cache values. If there is a need to change any @@ -4005,6 +4084,30 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = 0; } break; + case 0x8000001D: + *eax = 0; + switch (count) { + case 0: /* L1 dcache info */ + encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, cs, + eax, ebx, ecx, edx); + break; + case 1: /* L1 icache info */ + encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, cs, + eax, ebx, ecx, edx); + break; + case 2: /* L2 cache info */ + encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, cs, + eax, ebx, ecx, edx); + break; + case 3: /* L3 cache info */ + encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, cs, + eax, ebx, ecx, edx); + break; + default: /* end of info */ + *eax = *ebx = *ecx = *edx = 0; + break; + } + break; case 0xC0000000: *eax = env->cpuid_xlevel2; *ebx = 0; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index d6666a4..a8bf7eb 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -979,9 +979,32 @@ int kvm_arch_init_vcpu(CPUState *cs) } c = &cpuid_data.entries[cpuid_i++]; - c->function = i; - c->flags = 0; - cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); + switch (i) { + case 0x8000001d: + /* Query for all AMD cache information leaves */ + for (j = 0; ; j++) { + c->function = i; + c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX; + c->index = j; + cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx); + + if (c->eax == 0) { + break; + } + if (cpuid_i == KVM_MAX_CPUID_ENTRIES) { + fprintf(stderr, "cpuid_data is full, no space for " + "cpuid(eax:0x%x,ecx:0x%x)\n", i, j); + abort(); + } + c = &cpuid_data.entries[cpuid_i++]; + } + break; + default: + c->function = i; + c->flags = 0; + cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); + break; + } } /* Call Centaur's CPUID instructions they are supported. */