From patchwork Thu Apr 26 16:26:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10366331 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 796CC6032C for ; Thu, 26 Apr 2018 16:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B3D91FF29 for ; Thu, 26 Apr 2018 16:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FBA328A14; Thu, 26 Apr 2018 16:27:40 +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 17FD8289BA for ; Thu, 26 Apr 2018 16:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932272AbeDZQ1h (ORCPT ); Thu, 26 Apr 2018 12:27:37 -0400 Received: from mail-sn1nam01on0075.outbound.protection.outlook.com ([104.47.32.75]:11117 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932138AbeDZQ1N (ORCPT ); Thu, 26 Apr 2018 12:27:13 -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=5QHx01hMHYOcwUtJPHJDU2owDSP8wysEEsrl1lxUtQ0=; b=oCGeuptxbpiaviEAHVwrH/18PeWg6pkb1xCc7ODBsRvofK3C24MOSW7dah6s0twbtqDPvMqLsUt9neIWg6+Q6k/Li3hBe9IKxfC0wJJTfoA7x0LemdjL5gjD+hlfK/hcArDD8vcGMMNBKIbw79sjd4iX3ulavhQUamTNWcUr7KY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from bmoger-ubuntu.amd.com (165.204.78.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.696.13; Thu, 26 Apr 2018 16:27:03 +0000 From: Babu Moger To: mst@redhat.com, marcel@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, kash@tripleback.net, geoff@hostfission.com, babu.moger@amd.com Subject: [PATCH v7 5/9] i386: Use the statically loaded cache definitions Date: Thu, 26 Apr 2018 11:26:45 -0500 Message-Id: <1524760009-24710-6-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524760009-24710-1-git-send-email-babu.moger@amd.com> References: <1524760009-24710-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR1801CA0020.namprd18.prod.outlook.com (2603:10b6:910:74::33) 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)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:SN1PR12MB2479; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2479; 3:8a4bFzhBAwLpbKU7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6z4jM/PMZZLXGkOcGZc6ZPATU02PaRVTGEYn/iDGRc5BSg0sT0NaOndxcFSdI38gHBs67kom1d5aJqr/6anjex0ryg2RflNqQnskBiLhgHL0ppkxwAN/j+ZYP2KfSX7TZOH1H6bCEbjZc0ABkvRGXK49TG/N4ocLjv1wmY6lwGbz1NUgTlv1eO33zP85+p+OHJbDE/fr6djdrIjUmHjHnOlFhcwAg6i38qVZIcMxpr0Kj1+Z1RrFbCBVl31ZGbXYUhdIzF6x+gx9tY8WKy9ieB3IIMdKB/HYDeXg1PNfN37E+qFZa1e7LSBi0rvomH5/sHSIyR6rJEzL4mYF; 4:y7gNJ7+i2ZXDUOdw71Qbg3Dc7FqfiPXggC7LglX7Fpd9aIbFAsGREzT9NRFm08gSo1+3P9DaLTDTZZssHYQfe2L9YdNE5kPjI+MLsauFN5xO4K/avGWHFgtEvyVMDlyvHdKWBUffsWO+a3DBFS9zh80y1osIR+4KUEp9WnLIc7jhkDcH0SsJmwB/LQe71EzP/+TPrVAiav7A3yadJSJ48p3IZIVLWAHYOSgRLEJVlS2EF91UImVQGudwoDQ3wRMzl9cfuL6itrfiZxRLGMub7Phqvt782Y1WICJq4J9k5CkPczNeHebv01VjMq2B2RMA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231232)(944501410)(52105095)(6055026)(6041310)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:SN1PR12MB2479; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2479; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(376002)(396003)(39860400002)(346002)(189003)(199004)(68736007)(8676002)(2906002)(6116002)(76176011)(8936002)(5660300001)(316002)(3846002)(4326008)(81156014)(50226002)(81166006)(386003)(956004)(16526019)(7416002)(52116002)(476003)(97736004)(186003)(25786009)(86362001)(446003)(7696005)(11346002)(51416003)(26005)(48376002)(36756003)(16586007)(47776003)(53416004)(486006)(44832011)(106356001)(7736002)(575784001)(6666003)(72206003)(2616005)(6486002)(105586002)(66066001)(478600001)(305945005)(53936002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2479; H:bmoger-ubuntu.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB2479; 23:CtP1ARYaX/Kk6WicohUBrHjRj5DgSMqXS40yxrIE+?= =?us-ascii?Q?mspuDzRO78xkvH3lbUqT3AdU7Lzsia/dVIXWGP/oqRh1WiPP7TyimJEtVDQ0?= =?us-ascii?Q?eX3P/FM0lwOv1wYFV77g/6ZEg7eBJUoiuwjd5lG8CI79SVlr3RknyMfgPTEp?= =?us-ascii?Q?dg9YxBFVG35QK6S6xS9S1F1QqXVgZENVYB8kcpxkJIQQzZwcVvBedNhQR+ZD?= =?us-ascii?Q?UKylkWEeQHkRiI0j2tJKkwiaGcUHaA8BdYSAGXLoUzWU/bItc+j7OFY6I73B?= =?us-ascii?Q?4oVgDcgxN21SaVs9PobOOpid3sbjBREZTKipLuqVm8GBaa1qeKSE6KGnsAxf?= =?us-ascii?Q?ftU2kIseCR76ZSbP1L6kk61KHiQaGrTlu/E6cwLYcYpSg4HiDAOlXGPkw3in?= =?us-ascii?Q?PepecGRckfcPQgJl3R7oVhLj5GR9w6P8xtQA7Yv/xIIP5O5h03NCBhQhpsOc?= =?us-ascii?Q?TPheeJp/3VegoMmVb8hKwuCDGqdV7aiVu14UeLvkteRZOt39RcVY/MCR3mt2?= =?us-ascii?Q?PHnPVjm2yRKk3KWXAijwp551Z4azB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M6528QC+dNM1tr8BQMWyCWOPYYikGVqmKH6nLfa0YjKZFyVnnF3jIr2dy77s9Nhv4JhT2ymzFT3Bw84Dal5Yoq; 20:R+4p0biKq0UACCkOiEZnG7OxVeaTBHhVWgJl3OpcrzyKzsJND9FGa39BD0YZ9iAnvNqsfK57JuTDMvKicnScsIHj9MVjegbwbbA8JMrug9g9hoAi1RmEHWJkIyZPOb+86rZ7Bj5Debf+41Icz7Y8KpsfYx1C4hkNaDhAMJo1pMpNC5jdcxOWtjaRiCFbcaRSagNZ0mvkirXOUNhvMAxCqZkB3cavuQqcHVz2Yw99OCj8ZudoEe2Hxju2MHP42E6A X-MS-Office365-Filtering-Correlation-Id: c9862c0a-897e-4e58-535c-08d5ab928c2d X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 16:27:03.9398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9862c0a-897e-4e58-535c-08d5ab928c2d 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 Use the statically loaded cache definitions if available and legacy-cache parameter is not set. Signed-off-by: Babu Moger Tested-by: Geoffrey McRae --- target/i386/cpu.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a27b658..56d2f0b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3941,8 +3941,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, (L1_ITLB_2M_ASSOC << 8) | (L1_ITLB_2M_ENTRIES); *ebx = (L1_DTLB_4K_ASSOC << 24) | (L1_DTLB_4K_ENTRIES << 16) | \ (L1_ITLB_4K_ASSOC << 8) | (L1_ITLB_4K_ENTRIES); - *ecx = encode_cache_cpuid80000005(&l1d_cache_amd); - *edx = encode_cache_cpuid80000005(&l1i_cache_amd); + if (env->cache_info.valid && !cpu->legacy_cache) { + *ecx = encode_cache_cpuid80000005(&env->cache_info.l1d_cache); + *edx = encode_cache_cpuid80000005(&env->cache_info.l1i_cache); + } else { + *ecx = encode_cache_cpuid80000005(&l1d_cache_amd); + *edx = encode_cache_cpuid80000005(&l1i_cache_amd); + } break; case 0x80000006: /* cache info (L2 cache) */ @@ -3958,9 +3963,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, (L2_DTLB_4K_ENTRIES << 16) | \ (AMD_ENC_ASSOC(L2_ITLB_4K_ASSOC) << 12) | \ (L2_ITLB_4K_ENTRIES); - encode_cache_cpuid80000006(&l2_cache_amd, - cpu->enable_l3_cache ? &l3_cache : NULL, - ecx, edx); + if (env->cache_info.valid && !cpu->legacy_cache) { + encode_cache_cpuid80000006(&env->cache_info.l2_cache, + cpu->enable_l3_cache ? + &env->cache_info.l3_cache : NULL, + ecx, edx); + } else { + encode_cache_cpuid80000006(&l2_cache_amd, + cpu->enable_l3_cache ? &l3_cache : NULL, + ecx, edx); + } break; case 0x80000007: *eax = 0;