From patchwork Wed Jun 6 14:36:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10450333 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 78B6D60467 for ; Wed, 6 Jun 2018 14:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6995928F4A for ; Wed, 6 Jun 2018 14:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BA0929574; Wed, 6 Jun 2018 14:37:12 +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 9BADE28F4A for ; Wed, 6 Jun 2018 14:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752173AbeFFOhG (ORCPT ); Wed, 6 Jun 2018 10:37:06 -0400 Received: from mail-bl2nam02on0057.outbound.protection.outlook.com ([104.47.38.57]:49407 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752011AbeFFOhB (ORCPT ); Wed, 6 Jun 2018 10:37:01 -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=HP0RagRc5AgEeksaUXsOj7Y3OBrz44iA7vm2HMdzO5M=; b=WSjlfSj/oRZIyA60KfH2IJnZMTPi/5SpW4k0JmGLOPV4uePNgzu9d9/d8VpWn+W0ctaUjIwW6NMa4GkGQJwX5xD5ZZWEEen8PnSA330Ei3W2m6bwj37Am+GUYD8OebTaQ2rB5UwrSvTS6P55A1IPBRCo4nF4CaS8dm05kqwxjp8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-h3ml.amd.com (165.204.77.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_GCM_SHA384) id 15.20.820.15; Wed, 6 Jun 2018 14:36:57 +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 v12 2/4] i386: Verify if topoext feature can be supported Date: Wed, 6 Jun 2018 10:36:44 -0400 Message-Id: <1528295806-90593-3-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1528295806-90593-1-git-send-email-babu.moger@amd.com> References: <1528295806-90593-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN4PR0501CA0082.namprd05.prod.outlook.com (2603:10b6:803:22::20) 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)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MW2PR12MB2476; X-Microsoft-Exchange-Diagnostics: 1; MW2PR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9qKPrBOcMk5+IjcaBGPOpBOH7VB9TjEVjv7hr2Nr3UJDDPx6m5FDRbsHaoNlBY3ar4sS+YMVndy/OfPbz2xvhUMZKtQA0iONIsiErCdH7wmyOxO5KEmdcBCkdgAXZrvydkuM6kky1Kq+5X4HCkbpCyMJE/R0c0q1irVwcFFtorHsCza9yms7INxpoRCHYGdadKqSTLaSLNd6P6saE15kftMv47hG1UxFfEhDi2bA6ltu+Au0GW6GsJs9DMrqs7HPvsG4Us6BA4/zC+h9XcAlu+GLxdIqCJOGNYMaFpiwcCXkpghMGaiELYxbBrUwVMpZrLpucQRCyyfDc4hRGETFMaLFERZxYIYoKPrs; 4:Q4MeKlz/vEPPt70cwlsUH3WLDVP4nur4kDxNxBumn0OBpacHYQy0WnfKKjeHwGyRpY5PuflU/om6VpcvJHu6hPH5qWcUyFMKPgHXUmSFD6FzVeIsmc0T4MnmPAVRkQEOsYlZ3cz/48YtpTkmExI6l3Z3WmLSS8V3UxXeW9nymnBRCPKfS7IPxGsFolTs3Uii8UngWHjFxbXTnxBQXQUkBqw4m/aGaF8w/xBcXI5Xr8o+UchnJsX5l/lNpKtWnqCv3of2wshLHrC4DGKMRibRgEZrLjhsjiBT/HCSamSPsnEbT2w0kUX5NUCmUNJjGG2n 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)(10201501046)(93006095)(93001095)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:MW2PR12MB2476; BCL:0; PCL:0; RULEID:; SRVR:MW2PR12MB2476; X-Forefront-PRVS: 06952FC175 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(346002)(396003)(39860400002)(39380400002)(366004)(189003)(199004)(4720700003)(97736004)(26005)(50466002)(4326008)(39060400002)(7416002)(25786009)(3846002)(72206003)(6116002)(52116002)(47776003)(7696005)(386003)(478600001)(76176011)(66066001)(51416003)(5660300001)(81166006)(2906002)(446003)(11346002)(305945005)(8936002)(86362001)(6666003)(81156014)(16526019)(8676002)(53416004)(186003)(956004)(7736002)(44832011)(486006)(476003)(316002)(68736007)(36756003)(48376002)(105586002)(50226002)(16586007)(6486002)(106356001)(2616005)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MW2PR12MB2476; H:linux-h3ml.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; MW2PR12MB2476; 23:120FR/xYw2Ha6B8cBhsEIKojw5/EVrqNIw5eRr4ur?= =?us-ascii?Q?Y5r4arQCg1JyW2yQcjSX1pksgqu2HA4i4gTLICX/97C7sZtg6POb+QZ8L479?= =?us-ascii?Q?Mrai5W8N6norcrXYSQqrIW3PHVdbLqPkkAbv7X2uHcIDkvDBDch+D4tSZvDN?= =?us-ascii?Q?MR6p7asIrkHEWcSk5ir9f6BGgoimp8Jy9xEHZ4vwgjh8xugEqEvUMLRE5JIz?= =?us-ascii?Q?fqRBELBu1o8O53esfviXwyiQkxx0qX3DM4fEMDFxHi8QA7TezTZa3RetQ0Oe?= =?us-ascii?Q?vboLsyzmbihAEYt3H67WSqOII9+H4b9IY6E/vZV4q1EUntZ+/LTMo5kBwSfZ?= =?us-ascii?Q?Dq0KJoY1luqh4UK0Y9gCvQa4bkcXXkhp0Yh75kPveXh5R1g/xIpoYgibmm7t?= =?us-ascii?Q?Ak39Rm3ljQyKbnpDTJuW0rsYO3idyPSTsnXbBDWoXDrg8pkE8f7y0FUiS9R9?= =?us-ascii?Q?fcny44osapsLKu4Itk8+YXWdeYgsXsynoD3954aS7KpOkFat1c3jSFRn6pYt?= =?us-ascii?Q?7z/A8vjtfY1wYSeFmx6rhfjsaywOwlyhL3644TBKuUUAGp6ydZS8Jpxx8xBl?= =?us-ascii?Q?q2pSvo0eMcc38BBkiphzCsQI136sGTTJS92xcTt13YA466ossCEFu4yxcyRE?= =?us-ascii?Q?t7l/AHidWN+hJSDZKSI7DGf3apgyxSgyrxMKmiU55sVhKHJ8JSLx5HlIHZI/?= =?us-ascii?Q?yX03y8Ns9wPGOIGaDNNVKcPtl/RtkDS3V8nL5iCk0ew4VnU28N+EKseBbSTm?= =?us-ascii?Q?JynEB7KPJiDyNWuK/CWc6iHP/xrn82K4V5KaxZw/iny8B/w+qd+WM0K2LgRP?= =?us-ascii?Q?o4WJmX1j/5JgacrHuA35AtHzot0BVuMvFNsDkuy6MQVz5w4xxq1IRRvRRy/g?= =?us-ascii?Q?p5nmbI2KE+/WrtJ5xiE4PD+eHulj/E4FIyol9ENjC6vzHnqK2001tDJVq2mh?= =?us-ascii?Q?J7cZHsELJWArTVJG0L20l8kNQH6qPtDo2v3nv3dm2Zgq3KJbJI9RpC5q++0G?= =?us-ascii?Q?84EVkprhWSlTNdhUUkBq363LXnGOoOwmX3tGQcu/Ha+QKMSNhhljr16pWa33?= =?us-ascii?Q?H1OYn8G2C9g/Sp2FKlmjhfMlmyQSvJdDjYj1nAfTa6IK7V7hW2DDOgIOrB+N?= =?us-ascii?Q?3j/ZCUWoy3GvjX9ARsrR7GtddAhOy7OMCR0FbZixopRUUll/BvbO0OTBpNz5?= =?us-ascii?Q?Aa2zDZnvN6hAPVzQd3bR7MNcC2N+IUq+NZAykC2+lvp+o7MZ9r5ZywtBfTky?= =?us-ascii?Q?295+LK9LFONMMXPBV/rvmSMx4pRHSBZnLOxk6e/?= X-Microsoft-Antispam-Message-Info: OsAmoE1e48Q5oZ2JL64Ja/lZIaIEBzlBdk91jsPSFok9nN7nIYC4SazmuBSszvficciswmb1MSo4uO6ixNTucA8cELqNDNP/KBl2MPy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VL20KuQIkHXVygb1992eFItlu1qYAqAQZZ71lox40j9vefb9HISUSlSyvHQH5W9qcS6DRqX5AVE3aRzclqBrB3W06G/bqThGvUDYX3JammPbRXJiOjERSFgKdE8WUv27CUtj3lxtmgNwZQLIHkq7A0U; 20:vifh+0vNqQpCzx1JBAYw8aEZL7wngSLddBlRESH6Xzo90bS9SfDoMSZ3jHrggkeV4xFA8K/Un3XKiqbSPuzLM4TQWQe5TwNTir8l4pm4WBhCySYdWdhHbjR3jISyrMZcaZ9/3SOMgyDFv1YqNFKLh/fyuQjrT7OB3J1nf+WIUqUjo5e7L1xK6KlMBzfGjMLD36rOm/oeJx/9ssB5Jwm7pm/sxX9usCYU/xia8ln2oWtVykJ1yUv39HlNXFdSL1NH X-MS-Office365-Filtering-Correlation-Id: a8a50e38-1509-4cfb-75fa-08d5cbbaf59c X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2018 14:36:57.8133 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8a50e38-1509-4cfb-75fa-08d5cbbaf59c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2476 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP topoext feature cannot be supported in certain cases with large number of cores or threads. Add the check. Signed-off-by: Babu Moger --- target/i386/cpu.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 86fb1a4..fc5c66d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -509,6 +509,20 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, } /* + * Check if we can support this topology + * Fail if number of cores are beyond the supported config + * or nr_threads is more than 2 + */ +static int topology_supports_topoext(int nr_cores, int nr_threads) +{ + if ((nr_cores > (MAX_CORES_IN_NODE * MAX_NODES_PER_SOCKET)) || + (nr_threads > 2)) { + return 0; + } + return 1; +} + +/* * Definitions of the hardcoded cache entries we expose: * These are legacy cache values. If there is a need to change any * of these values please use builtin_x86_defs @@ -4941,6 +4955,19 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) qemu_init_vcpu(cs); + /* On AMD systems, check if we can support topoext feature */ + if (IS_AMD_CPU(env) && + (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT)) { + if (!topology_supports_topoext(cs->nr_cores, cs->nr_threads)) { + /* Cannot support topoext */ + error_setg(errp, "CPU model does not support topoext feature " + "with number of cores(%d) and threads(%d). " + "Please configure -smp options properly.", + cs->nr_cores, cs->nr_threads); + return; + } + } + /* Only Intel CPUs support hyperthreading. Even though QEMU fixes this * issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX * based on inputs (sockets,cores,threads), it is still better to gives