From patchwork Mon May 14 16:41:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10398911 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 E25B86038F for ; Mon, 14 May 2018 16:50:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0B2E28707 for ; Mon, 14 May 2018 16:50:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2997C28742; Mon, 14 May 2018 16:50:48 +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.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F07A2867C for ; Mon, 14 May 2018 16:50:29 +0000 (UTC) Received: from localhost ([::1]:47218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGg8-0003M9-G0 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 May 2018 12:50:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGYH-0006q0-QO for qemu-devel@nongnu.org; Mon, 14 May 2018 12:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIGYE-0005gr-Vy for qemu-devel@nongnu.org; Mon, 14 May 2018 12:42:21 -0400 Received: from mail-cys01nam02on0046.outbound.protection.outlook.com ([104.47.37.46]:60455 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fIGYE-0005g7-PO for qemu-devel@nongnu.org; Mon, 14 May 2018 12:42:18 -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; bh=20WZV7ksie1BCfXV73vd5QmOsxtL5Wp7jC2vCCYutPQ=; b=2ztMfe3R32F3+9f5bGU/6jtZaiUPTR5FpWBFyfwG60fScSsBKVMikLcwixupN24mb60x7VKgT9a8+kkmL4Fn1Q6ja0LaLgqNsfPHq74TJBZasFxmgvBK6xH3aIgbMzf0yrOY7iCPT5Gw3UmbI+fbDXi9F+Ryw21WiA50BqTXE50= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from bmoger-ubuntu.amd.com (165.204.78.1) by MW2PR12MB2476.namprd12.prod.outlook.com (2603:10b6:907:9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Mon, 14 May 2018 16:42:16 +0000 From: Babu Moger To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Date: Mon, 14 May 2018 11:41:52 -0500 Message-Id: <20180514164156.27034-4-babu.moger@amd.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514164156.27034-1-babu.moger@amd.com> References: <20180514164156.27034-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0701CA0008.namprd07.prod.outlook.com (2603:10b6:803:28::18) To MW2PR12MB2476.namprd12.prod.outlook.com (2603:10b6:907:9::15) 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:MW2PR12MB2476; X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2476; 3:3mNOM0eTLYo6cbd+dUgv+3zBiCIyPmaeyobLplWj/UqtPi+/2l2+wLXEtO5YDpfoyT4e63wPMHXj4dyPGvHi4MdqojPdbo33yImnztTty39UYnas0gHquzXNzMDN82U1AOEIfzc2JkubMvJb5cLvUfaQZFkbfAYbP6yFexSs+zuQBbuw32UcZpgnQ28OFbBR9YzDw/6E9KDOIpb8Uv7m7OkKRy6gw1uJiCaHL1YURL1+KcVn1Qt4zyVFl6uRCPNx; 25:f62qun7/6BVZhsBoi/rdnD0hGfl27wCvteVcKyP0ICGqay2wQU+T5U9VqYyKZcglzH8cWbIrqdQftpbhfOXg4Y3mOTGa3Xzqq32WGZvnarEvqFm4w2Eezpm1DxgT67h5DCeLYANyp9p9dBG3ArO82jxf76gK4o/cah6kDQVgVNd3J4Am6Gttlk0Pla5ge6nVHrUBGfg1HERM0u9uTnsboDM0lU6KaqM6092ufuc3SZjjCO7nktN0/JsTULTGbYaEmmfdSCJXOF9tEgOyKy0QtYzyw9Y9CM3pe5PTKN0vYNeGLRoED2fP5GqBHC9tvezJtKLWUGF6V3+UMlopCFfGAA==; 31:UDDF7SSk0rI9VXnXU0XVSd+TaJcNzrZU1P+gkOpu3bh+pFfZDXMnooO5n9WL39C1W1D8oC0V4hY7Q6TFMz6QZtkOBYv2u56GhgAa2XFOvpZE+OUzn4BeRr2BOeBvjvSZiOR2Uxmr38JKqHyYzxp00ntLLmhmgGE/WXT3H0imhTMoJoVhBr/WSIwJCxQ9/WFaqnj1Ci1JZomF45q5G/XQLTz+TN+bAfQIj9aeBrywpDw= X-MS-TrafficTypeDiagnostic: MW2PR12MB2476: X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2476; 20:u72MDRAWgiFKxEQLU0VLNK1JRXn1emlaMdi74mlkTrsmDFhpbmTKTUjBUpzlEY5WB1qK0DmMWdQEzGzl/IJQzUanX0oBJmxf3obi4AL9o36OHMnx83x+2h3PcgnTCU5rcc+3mhvd2LCOWFj+gRzim2pvfRssRckz5FoPkPj5XIaBN5ZkkfXSvqZpqNfapuu1+BTKvaj/14+C6QINUTrYRHgQ6dgp7MpvH4fRdlcQIVrFewS3cYZtwl9OL5hXg2LIfXkuRDMsG58il6bbxXckBm7wjgj5OAAe9NkzN7+X+3TKO6uRGNomvaYJ5uXtqXPdExm7cGb3h0J/qG8j+o8DT7MuE3YWFYB0ULfo5aAFvp4byVSJsNNv9A7II1i629MLx9/5osUKAouZQCFNXL9iT2K4CcpJUjPR0xLupmwk3rCpHfC9e5GZ7VSzEyI4VVj+f598P63cclqYSZvk3UY0kx4UoE5b3WvivjY+v1/ABCKZyodjz+rHJ9Dc52Sia1l2; 4:WiqjSLdrjTd2BdwwCV0M9fqmWKF/OWVpuaxWAz5kudLPnbbnoMou+Pg0cwKkw+SjKu8tbHjyT3nv7MsM6pAiL+nZhkGGvJC+BmjZ1dZ08wAaUihejlQGyVPdY9jhaqxfJh1Pqgh6RrUa6hjSmkdL/jvs11Tcx/BmDC9IPzeUv+aBpLDn7S67VCYeNRY5hbe1B3zCOUL0MW8Mw6We4MI8N7hiu9rtn6dRfboVKs4Nt5CKnj2Av86kHRGKQtciQUN16wCnZYt/PuIIJ+NISBbPRfmnxhzkdQlLBZ/VHdt2iHRm445PsoHbBLtKOPlveQYU 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)(5005006)(8121501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:MW2PR12MB2476; BCL:0; PCL:0; RULEID:; SRVR:MW2PR12MB2476; X-Forefront-PRVS: 067270ECAF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(39860400002)(396003)(346002)(376002)(366004)(199004)(189003)(50226002)(53936002)(50466002)(8936002)(8676002)(39060400002)(48376002)(2616005)(486006)(476003)(305945005)(25786009)(7736002)(6666003)(446003)(11346002)(956004)(5660300001)(76176011)(186003)(36756003)(86362001)(16526019)(81166006)(26005)(4326008)(386003)(81156014)(7416002)(106356001)(53416004)(72206003)(97736004)(316002)(47776003)(478600001)(105586002)(51416003)(68736007)(6116002)(3846002)(16586007)(2906002)(6486002)(1076002)(44832011)(7696005)(66066001)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:MW2PR12MB2476; H:bmoger-ubuntu.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: =?us-ascii?Q?1; MW2PR12MB2476; 23:Y9nqJZcZkT7s2436iPH86HxybQklWulkzxWTqlASy?= =?us-ascii?Q?wVGuReg70YcoHRknDp/Jbu+8qQRaJ/mtHSk9pepjxan6+lE+n0SJNNpQpybR?= =?us-ascii?Q?HoPrxFxwR1WJv2jxs7JJ2VSlDc5VlMh0z5Ws76L+aODpyG/UZajxVphFMVIn?= =?us-ascii?Q?yl1N4wd+uRCVTARDMLMN0tvftU2ruI201OyniJaFYvaqjb+k64/xiVKCPhYi?= =?us-ascii?Q?lSvJk5ijfMttxJ0PUyleql5AkMF0K6XPia63JqS7WEnQYTaxS0DM3JmZDbmK?= =?us-ascii?Q?jkCtsq70aSlzacSeXs4iLkb0NBIA4DGLnZGy8nRCAXijBSRgse+alC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uKTuXff4NL9Iwm013XYnJLsd4llljMNRnZVI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2476; 7:TXIQ5w34vAFIEniTsUXZ3a65tUiY8SMRrhMTt+pzyqkbIyc/+Cnv+EXtnBrkBKr1kdUHsWjENLyF3Fiof9HchMQjG5nuqr7PBCVlFy+jtJ/BCDJ2mm28c/9XrTjr3GVJRpeV1UZe+4RObsCzGPqx+hLSi5OVCw6Oh1Sf2rbiPKEboFoPpLhGYIoQADpgYukOEh3+4cb3rlVBMtZyApSLLPfKArLUaQCFmqsKIB4QryM1ODkYvFWVV7uw2tOlsBRU; 20:iP1HXgQlBJMFRkVlClE/QCyrS0tj0ivtENRFl3qqeb1mD3XVngBFDujMmCjsotcXvuopw1GdfFUO1Scs/xXfdi3rkqyU5w7JfDL/qozCu+J441I+/BuZlfwKDbFKWi7hPrDV2r6XRia+7QRD3xYTqgryHHnvSzv28OXEUoC+6hKBMywXTL+jqTeVnjCjCviCD8Ju7cfA2zAFP8L5vfYU4AhfnWjqOXrpcZxA+LElhIUyNmEZObWKXSeOXUuUnyE7 X-MS-Office365-Filtering-Correlation-Id: aeb0a18d-89ef-44a6-a2f8-08d5b9b9a74d X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2018 16:42:16.0545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aeb0a18d-89ef-44a6-a2f8-08d5b9b9a74d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2476 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.46 Subject: [Qemu-devel] [PATCH v9 3/7] i386: Populate AMD Processor Cache Information for cpuid 0x8000001D X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: geoff@hostfission.com, babu.moger@amd.com, kash@tripleback.net, qemu-devel@nongnu.org, kvm@vger.kernel.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Tested-by: Geoffrey McRae --- target/i386/cpu.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ target/i386/kvm.c | 29 +++++++++++++++-- 2 files changed, 105 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e1daff37ab..7f40241786 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -307,6 +307,14 @@ static uint32_t encode_cache_cpuid80000005(CPUCacheInfo *cache) a == ASSOC_FULL ? 0xF : \ 0 /* invalid value */) +/* Definitions used on CPUID Leaf 0x8000001D */ +/* Number of logical cores in a complex */ +#define CORES_IN_CMPLX 4 +/* Number of logical processors sharing cache */ +#define NUM_SHARING_CACHE(threads) ((threads > 1) ? \ + (((CORES_IN_CMPLX - 1) * threads) + 1) : \ + (CORES_IN_CMPLX - 1)) + /* * Encode cache info for CPUID[0x80000006].ECX and CPUID[0x80000006].EDX * @l3 can be NULL. @@ -336,6 +344,41 @@ static void encode_cache_cpuid80000006(CPUCacheInfo *l2, } } +/* Encode cache info for CPUID[8000001D] */ +static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, int nr_threads, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) +{ + 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) { + *eax |= (NUM_SHARING_CACHE(nr_threads) << 14); + } else { + *eax |= ((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 @@ -4035,6 +4078,42 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = 0; } break; + case 0x8000001D: + *eax = 0; + CPUCacheInfo *l1d, *l1i, *l2, *l3; + if (env->cache_info && !cpu->legacy_cache) { + l1d = &env->cache_info->l1d_cache; + l1i = &env->cache_info->l1i_cache; + l2 = &env->cache_info->l2_cache; + l3 = &env->cache_info->l3_cache; + } else { + l1d = &legacy_l1d_cache_amd; + l1i = &legacy_l1i_cache_amd; + l2 = &legacy_l2_cache_amd; + l3 = &legacy_l3_cache; + } + switch (count) { + case 0: /* L1 dcache info */ + encode_cache_cpuid8000001d(l1d, cs->nr_threads, + eax, ebx, ecx, edx); + break; + case 1: /* L1 icache info */ + encode_cache_cpuid8000001d(l1i, cs->nr_threads, + eax, ebx, ecx, edx); + break; + case 2: /* L2 cache info */ + encode_cache_cpuid8000001d(l2, cs->nr_threads, + eax, ebx, ecx, edx); + break; + case 3: /* L3 cache info */ + encode_cache_cpuid8000001d(l3, cs->nr_threads, + 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 6c49954e68..6e66f9c51d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -967,9 +967,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. */