From patchwork Thu May 4 20:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDB41C7EE22 for ; Thu, 4 May 2023 20:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbjEDUya (ORCPT ); Thu, 4 May 2023 16:54:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbjEDUy1 (ORCPT ); Thu, 4 May 2023 16:54:27 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2072.outbound.protection.outlook.com [40.107.100.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6C7A270 for ; Thu, 4 May 2023 13:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ErqjifAuANbJsZEVJ6QoqzkxjKYDvihSnkuMt8FIi0H/GA1szp62hDvioevQhdRcv3lsFLhLBe7bZnG/1uyp7vtvWb5T3PrJemliWwq3IDuOaZihOZQB7dJyt1hwNQ8veqzx6zThSw+TY5qw9sSul7JEnnk+YfhGuVkQM8PVaWMc7wlRVUK2lm9Hw9gKLI7N4AL4rCNsouWhzjCb+AhdHzVtkdQ7wP/103EAoXtnBJrbkRQXhrHYwIj5TpAJ6/YFj5yGN2Z+W8ICIB33ecF3lm3xhUWfjZ4GVtnJB2JKswhpjpc9lH2ucuDI42JjoUnUftadh8hFXj8xWkLFdN1pMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QYcnc4H9ARvb3HyRAdSp8NVzqXsbscxUazPWWvlYKzo=; b=Wa1MGN1eo8DtB0YKAVcejkptc/JBU1dogPAAtBzI9QZJtpp+GO0lLvWzZVJsoR6q0ffmcDgnNKuIKuoC/0L4ouwA9/6IqxJUh5qn6czOVzJtR2F8FssZDUgzMw+UPOg3RjIMTPwgLiya/DCpp6jLzip2JqNfNoVXL+CL51GwJmCYSOKtg/a60IQ9OamiWJq7TsuIOKgx1TaEiN28xlrxJBsqVxKH92mQh4to5Z69OTyTAa1HzjxqPVkgk4r+3nfN6G+cVCXNSoq3oAg+S0BW9bNLCBXKbL3TtaDipzVeXAhV+Wpa0oxu1L8ve43Ii3Lh9oq+OVPS4uZgjqk+LCPVhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QYcnc4H9ARvb3HyRAdSp8NVzqXsbscxUazPWWvlYKzo=; b=3OO7Z1f6DOBUMGM36b02j8WmCrXHwgwsii5yC0djtaooGuigGkr8tN3TWkF/kf8CjCPyGx0WsAomPHFenoDH8F23XwgKN4r1KKTwPi3aebDGiS9A9D0oQrWpMyWR3WwyRD6W43Yb16HKByq25mxVif2orX+c27/ksJSWOdnI1D4= Received: from MW4PR04CA0192.namprd04.prod.outlook.com (2603:10b6:303:86::17) by DS7PR12MB8204.namprd12.prod.outlook.com (2603:10b6:8:e1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 20:53:30 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::48) by MW4PR04CA0192.outlook.office365.com (2603:10b6:303:86::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.27 via Frontend Transport; Thu, 4 May 2023 20:53:30 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:23 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 1/7] target/i386: allow versioned CPUs to specify new cache_info Date: Thu, 4 May 2023 15:53:06 -0500 Message-ID: <20230504205313.225073-2-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT046:EE_|DS7PR12MB8204:EE_ X-MS-Office365-Filtering-Correlation-Id: ac4a66cc-2100-4f0b-60dc-08db4ce19e05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F6GG0c9rqeXrA2n9ltWtHpWenRMvOfIQmAae5Y05yCdh3QTADOjbG/dc/Rt55TJ5p11Wj7ZIw17a9/WCImoesVNhMjMphM1b4lglQ34abte0XusaiVi0FwxJixw04f9qPF+AGD5BjWnLAAly96EVgC9FoHfgADKY2WUIaamaj7hViXVak5+h6aSVGgcAzIZOHEkW9pgNONzY2TgOlbH7+9j8S7cGYnJHd2mzPtnq0qinGtGJL0mv4SWD/jP8rkfoPH61DFIdSrNGkz88rju2upWJRbhHZpOrgPKHc8rtx4xgxpDd5Z1XaoofffQbkxsbdJZA8cCYEDotzAHQ2yS6wvzbuzGrXzOQTWu7VVY5QR+o4vXD6Kgx5h7oZrUlS5OmKsn1ZhSx2/l1JcVhOexA2NITJ+O0tnk8igDLjLZsPsxybrdb3o81nDtAiH609JGllCX6DiKWHrjxPg2IZoHZWzI+qrjNDvGjtKbdmFZln33S0c3VdYArAT2bGpa0PQ/Gh93zZpbSm7lkTL4BaLCw4KoKNz0medSNrb73Jkry7tR7MtiMnATFdwBtzeYpejFQTbeUhNf4xXuPq/hM1FamrvSsPx4+E4feVrPT7aW6PBB+JkEdeE0S9uZIgi0+53wP0woM9Dbunff7i5wTqmImc1Mh6vyR7IAavTWtxpY4jNgYCksmb3dPm7WXobo1QqKg6nhrtijJLGPFz1Va6fvmIgGCnf3hMpVyTmxLZEo3Tkc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(478600001)(4326008)(70206006)(7696005)(70586007)(6666004)(54906003)(316002)(110136005)(86362001)(36756003)(426003)(47076005)(336012)(26005)(36860700001)(1076003)(8676002)(8936002)(7416002)(5660300002)(44832011)(41300700001)(2906002)(82310400005)(40480700001)(356005)(81166007)(16526019)(186003)(83380400001)(2616005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:30.3843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac4a66cc-2100-4f0b-60dc-08db4ce19e05 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8204 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Michael Roth New EPYC CPUs versions require small changes to their cache_info's. Because current QEMU x86 CPU definition does not support versioned cach_info, we would have to declare a new CPU type for each such case. To avoid the dup work, add "cache_info" in X86CPUVersionDefinition", to allow new cache_info pointers to be specified for a new CPU version. Co-developed-by: Wei Huang Signed-off-by: Wei Huang Signed-off-by: Michael Roth Signed-off-by: Babu Moger Acked-by: Michael S. Tsirkin --- target/i386/cpu.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6576287e5b..6e5d2779c9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1598,6 +1598,7 @@ typedef struct X86CPUVersionDefinition { const char *alias; const char *note; PropValue *props; + const CPUCaches *const cache_info; } X86CPUVersionDefinition; /* Base definition for a CPU model */ @@ -5192,6 +5193,31 @@ static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model) assert(vdef->version == version); } +static const CPUCaches *x86_cpu_get_versioned_cache_info(X86CPU *cpu, + X86CPUModel *model) +{ + const X86CPUVersionDefinition *vdef; + X86CPUVersion version = x86_cpu_model_resolve_version(model); + const CPUCaches *cache_info = model->cpudef->cache_info; + + if (version == CPU_VERSION_LEGACY) { + return cache_info; + } + + for (vdef = x86_cpu_def_get_versions(model->cpudef); vdef->version; vdef++) { + if (vdef->cache_info) { + cache_info = vdef->cache_info; + } + + if (vdef->version == version) { + break; + } + } + + assert(vdef->version == version); + return cache_info; +} + /* * Load data from X86CPUDefinition into a X86CPU object. * Only for builtin_x86_defs models initialized with x86_register_cpudef_types. @@ -5224,7 +5250,7 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model) } /* legacy-cache defaults to 'off' if CPU model provides cache info */ - cpu->legacy_cache = !def->cache_info; + cpu->legacy_cache = !x86_cpu_get_versioned_cache_info(cpu, model); env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR; @@ -6703,14 +6729,17 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) /* Cache information initialization */ if (!cpu->legacy_cache) { - if (!xcc->model || !xcc->model->cpudef->cache_info) { + const CPUCaches *cache_info = + x86_cpu_get_versioned_cache_info(cpu, xcc->model); + + if (!xcc->model || !cache_info) { g_autofree char *name = x86_cpu_class_get_model_name(xcc); error_setg(errp, "CPU model '%s' doesn't support legacy-cache=off", name); return; } env->cache_info_cpuid2 = env->cache_info_cpuid4 = env->cache_info_amd = - *xcc->model->cpudef->cache_info; + *cache_info; } else { /* Build legacy cache information */ env->cache_info_cpuid2.l1d_cache = &legacy_l1d_cache; From patchwork Thu May 4 20:53:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1DA8C7EE29 for ; Thu, 4 May 2023 20:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjEDUyb (ORCPT ); Thu, 4 May 2023 16:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjEDUy3 (ORCPT ); Thu, 4 May 2023 16:54:29 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A77F11DA2 for ; Thu, 4 May 2023 13:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jw7duSI1ksf2PS8CvH7lXPwmhKFUd5oT2WuKm42XHF9YQ6c0WcZTLG7kuKMQcWGY3n64oOq3XqM1y3BaR+RqWp2PxXpN89F/zMH3+8HM8VE/rs9WHQ/cc3o5dnwK1no36/AFVuFTcbbTJI6Iw4mpxNcYdSa94S2C7JprTTzQHZhp7OxPopFNNYa4FNCK6hgE3rnyJD0DuSrz7huMI67fzQFcipfbS8N0kfNyM/BfIxjIRSpK8YaOtiPjKKhEEi0F38VwZ7JF1JxNvORribpZwS3KbxkBBc+BW2ix3UltUmTi14Dq0DX9ULOELymBGXETdH9vFR9JtKQ1UHQiwkdjtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kVKaQfSRr/cnJ8adibRf57IBypTIAIUZWNHemCMo5Qs=; b=aCNW0CeDdqlBbHrCgKbL90+Phjm5MkJyggK9YskHYb5QtDZqwGuNRIwWrB+SEUV68EDFd2HZ9+bpf91hGXSYUPF4b6LGexM971p3GRO/6oTgOPzdeQvtYg5Fwsut4ldUFu/DAY4n82TnrPJDJkHba0uF7IPnUH17K8NX314NBDxWr0aoadFJYkRuin4LPeE2Ss4rR7t3uzVVWOXEF1WVNgrQ8pauKAr+RZkmeB2qvco/J6GLu7XuL4Nxvp4TL3M5j7/jjN+O/i9lYiqUO2KZUEVhWLw9XsJCuKS/zmzq3JkdMLxJjhlH7IGCbMo/pY94ILF41SObhaVJt+EOPPwf6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kVKaQfSRr/cnJ8adibRf57IBypTIAIUZWNHemCMo5Qs=; b=lJhoJW1QTNykjnX75orUl8i2mm45+ViBYMiQf2NglSLvMPCRQd8XBfeBZIf9lkUZyBGivKHgBrc+nfxhm3R6MyLfE0YNo80Tu1WTxFDz148RqfDVfHpPNNTRI8mrRL/LjL/JcadzRTCy9oorV8ksjzQ37cPRtpsn9ZAnqwlrpQ8= Received: from MW4P222CA0028.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::33) by BL1PR12MB5729.namprd12.prod.outlook.com (2603:10b6:208:384::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 20:53:29 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::22) by MW4P222CA0028.outlook.office365.com (2603:10b6:303:114::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:28 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:24 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 2/7] target/i386: Add new EPYC CPU versions with updated cache_info Date: Thu, 4 May 2023 15:53:07 -0500 Message-ID: <20230504205313.225073-3-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|BL1PR12MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 15a7d20b-f5b3-42c3-de76-08db4ce19d15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zWT4KbQiojcR2l+Sl1w/EHfb3r4u6qoorZRQPWZDJxUeawx8OndMHKN6+AGCUoUZyHzvCRq++P/MIX0ccAbfbewl/5Mw8EuBrFSqW9OBBkzAT4u0/CZiMFhqN/6dYHqGb5y3opw8Xb8VFwj4R5XR9/TVUd0JsGjpBaf2zGPnKigSi5OXYyqSJXGmaWe10OPL+I0SF9BFHZR/6FEvUMZBTrPpNBr68Iq/D+e4hCFUCwVBzXmuPE4CUEsWv3q5f4lPIqoGeEgsaA6jhCMVnMfS5A/cu1v2/QqkLDgKHcCeWflcGAkXpqDSrFMKm2cRJrVVYu2h7Nw9azWD83lt7G/cD2Cxn6RGGzI2syIuteia+WfNDN65oEVGl/scri1Th42odVsviaVVQFO4HP6SLoQGs600vtY+fTrBXWaLhjjPg36tGc0KQtBDcC+ZQwQ0QtYR2wbdBZguZFreV5oI8nFkHcRzl1ZCd5Y1aPDolULjbC5+4QghD9kTmlQ4kjCGKfGvx3FXzYBykzS3gJJfIjm953UhqJXPtMNgUvjevu0g0vq0nh4ANmGhtvg9Is4k7uUfcDtUYTFer+9pOjsk0qc0jVbmCzsfGeg83mSDYiEUO1gI5UmUnekgxQvUJsvrZbAmES8TC/kD/XgZ3Bq/uO7UuKkFnV+51WIkkjy7sm5WWmX1SVdjf+wnMrtuZsD8wKAhAnh+xqCCOxn8NVvyOCFIFQ1REvnCGxv9piBLpN22Nhs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(8676002)(8936002)(36860700001)(40480700001)(36756003)(356005)(41300700001)(82310400005)(82740400003)(6666004)(70206006)(81166007)(70586007)(4326008)(316002)(86362001)(478600001)(110136005)(54906003)(40460700003)(7696005)(2906002)(2616005)(5660300002)(336012)(15650500001)(426003)(1076003)(16526019)(26005)(186003)(7416002)(47076005)(83380400001)(44832011)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:28.7522 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15a7d20b-f5b3-42c3-de76-08db4ce19d15 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5729 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Michael Roth Introduce new EPYC cpu versions: EPYC-v4 and EPYC-Rome-v3. The only difference vs. older models is an updated cache_info with the 'complex_indexing' bit unset, since this bit is not currently defined for AMD and may cause problems should it be used for something else in the future. Setting this bit will also cause CPUID validation failures when running SEV-SNP guests. Signed-off-by: Michael Roth Signed-off-by: Babu Moger Acked-by: Michael S. Tsirkin --- target/i386/cpu.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6e5d2779c9..6c20ce86d1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1707,6 +1707,56 @@ static const CPUCaches epyc_cache_info = { }, }; +static CPUCaches epyc_v4_cache_info = { + .l1d_cache = &(CPUCacheInfo) { + .type = DATA_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l1i_cache = &(CPUCacheInfo) { + .type = INSTRUCTION_CACHE, + .level = 1, + .size = 64 * KiB, + .line_size = 64, + .associativity = 4, + .partitions = 1, + .sets = 256, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l2_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 2, + .size = 512 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 1024, + .lines_per_tag = 1, + }, + .l3_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 3, + .size = 8 * MiB, + .line_size = 64, + .associativity = 16, + .partitions = 1, + .sets = 8192, + .lines_per_tag = 1, + .self_init = true, + .inclusive = true, + .complex_indexing = false, + }, +}; + static const CPUCaches epyc_rome_cache_info = { .l1d_cache = &(CPUCacheInfo) { .type = DATA_CACHE, @@ -1757,6 +1807,56 @@ static const CPUCaches epyc_rome_cache_info = { }, }; +static const CPUCaches epyc_rome_v3_cache_info = { + .l1d_cache = &(CPUCacheInfo) { + .type = DATA_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l1i_cache = &(CPUCacheInfo) { + .type = INSTRUCTION_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l2_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 2, + .size = 512 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 1024, + .lines_per_tag = 1, + }, + .l3_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 3, + .size = 16 * MiB, + .line_size = 64, + .associativity = 16, + .partitions = 1, + .sets = 16384, + .lines_per_tag = 1, + .self_init = true, + .inclusive = true, + .complex_indexing = false, + }, +}; + static const CPUCaches epyc_milan_cache_info = { .l1d_cache = &(CPUCacheInfo) { .type = DATA_CACHE, @@ -4091,6 +4191,15 @@ static const X86CPUDefinition builtin_x86_defs[] = { { /* end of list */ } } }, + { + .version = 4, + .props = (PropValue[]) { + { "model-id", + "AMD EPYC-v4 Processor" }, + { /* end of list */ } + }, + .cache_info = &epyc_v4_cache_info + }, { /* end of list */ } } }, @@ -4210,6 +4319,15 @@ static const X86CPUDefinition builtin_x86_defs[] = { { /* end of list */ } } }, + { + .version = 3, + .props = (PropValue[]) { + { "model-id", + "AMD EPYC-Rome-v3 Processor" }, + { /* end of list */ } + }, + .cache_info = &epyc_rome_v3_cache_info + }, { /* end of list */ } } }, From patchwork Thu May 4 20:53:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 408C6C7EE21 for ; Thu, 4 May 2023 20:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbjEDUyk (ORCPT ); Thu, 4 May 2023 16:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbjEDUyd (ORCPT ); Thu, 4 May 2023 16:54:33 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26194120B7 for ; Thu, 4 May 2023 13:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m2PHR816A81/dNtyT5gY+LhSfdySIQjG76wak+HrX1PPrgZ+CwGVqzENP0LO4gdZiM0wJToKWqYfjupMkz4SCs7XGOURI071nMy7dtF3SBkjTLSljWaJV+PLTLxpDVpVFEVQ7oTcrY/6RLbGPDDJ48bkX6fVj1HGLJzhr6VgFmxSVbuEZGPu8JiAccCHviwaj5lyMT5TjAMABxUnLMmFd4ZezxhTrAeChL8/KvATgBwLg1bFL8R3sm+zhICDur11Ya3I5h/X6Hr4PT5P0aH6HIDAcSZ5iuZLDusxhkkpI6miKBBOdSE1SzHRtQ/UeZSV6OBeIMIWk/WECHomUBDKKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BDSW8af148/ffO20p+wYRn7eBomWU7Qujvr+JkFP0Uc=; b=boFU1hJCGQdn2WE+dizRzUOUJUbVgcQtiiaAHji7LIOyUccWwRfEWuacJbl2ynuYwP8PNlLooe9gWGV32HUKAb9h73fGqoTQw4fTxd+3nmZU4QFJ9TnGmNMzSn3txGq2iLkJAH9F6xSaQEW3su373JzvagGJe76d95gJUftux7pr0ed6iW2j47lnLCioBMQ4SpbTLM8TsOronRACC+rXxTNRaYMdLhfelFxeVgCGEW9SyuhXUtA2yjrpM06z5tIG5vM/RI9C/D9q6wI9vCdnp6gTIBXNMQ0w2Wzy+7RLk/vxRjAw0pif/PW/pXKfdGN5iyvjFIZg49kyNYB2BjkFcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BDSW8af148/ffO20p+wYRn7eBomWU7Qujvr+JkFP0Uc=; b=iek9BOfM3Uzgv2ReOOWAfH2BjAmdyCr5pQrPHs8m97u55RctcOp4zvHE/VOYPB5Pko7lzfN7l3aruYZLZ4hkhhvQZdLsfpjeQI4XiN5y6YV04kSGa8gHfy993iB7w8Ri6mMEBkVlnGnE9Ilv/J01M7vHcVERoVEg3KCaosQjOo4= Received: from MW4P222CA0014.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::19) by BL0PR12MB4963.namprd12.prod.outlook.com (2603:10b6:208:17d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 20:53:30 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::da) by MW4P222CA0014.outlook.office365.com (2603:10b6:303:114::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:29 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:25 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 3/7] target/i386: Add a couple of feature bits in 8000_0008_EBX Date: Thu, 4 May 2023 15:53:08 -0500 Message-ID: <20230504205313.225073-4-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|BL0PR12MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: cbcee338-9d71-4370-bff2-08db4ce19dbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w3uWVqA8w0ImeiIf3uI60WdSP19Zagi+Y2T17R0cyT2+hkMsXy2i0rtnt4YgG/YfgUT+TVfdr5KTW9RnGTLILoaoYGBhyRoUNatQhxo4yMUEGX7laak4JcRK0qfvsV7/aYmoE+BGa4pMV96BvmgQc2oPBmQdHnmLC9SdFe2eJlwKrzAEHpc21CThYoIoudZoDvIc80ZgGuiOUbN7hDnbS61+3Ao3XfCnKRjbvGfmoGcRhJjpYiJ7/w/6CW9KVjL1JAft32vyO4ouw+HTg4mZcItJ0yNNn+BJ/90oDJjCXVLT9luH0wDMUqhGxJ9JGRmwCqCcW+AIOtdd/aGUjFLW42KqMhBZKSPRSj2B9iIIPdRJ/lDZiRls2QNTNXpEv0ui4kU8Uq+IfcT80fMBDssIZfGmjz/j2qfUY4jxdHMzuICahcUGo9xKXNe/9ArRZHZGk3SzX4tZtVs9RneLn3SqazN+TbpnyRiA/gxu4BPN4JMbJZt2mPmiuhFeeZWyuHEFJYTkGeNTC+ciWJHQL6vmWW4CNsOoDWyPeuVFHeCeITHU7eyJVbrTyVi4135ZSJkSA/D+vKMDu5DNPmdYNzkDdt3sGH4YtFpDVW8Jm2ZsHNNRtbA+K4U3DvFaDE4ZEL96BBDQwX5c7cAHzeGWhpte6UvfTxteKsRR0jBIudaww2GKuF680NOug7oWL3AN3mG5APYekDw8NhyX6H7d+IZq/8etq2NV7Kwpu7gWZ1O7ePEtX3xTrI6lhHblPevLM5/xPXVVxxRSuZIim6mKQt1T6g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(478600001)(4326008)(70206006)(7696005)(70586007)(6666004)(966005)(54906003)(316002)(110136005)(86362001)(36756003)(426003)(47076005)(336012)(26005)(36860700001)(1076003)(8676002)(8936002)(7416002)(5660300002)(44832011)(41300700001)(2906002)(82310400005)(40480700001)(356005)(81166007)(16526019)(186003)(83380400001)(2616005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:29.8927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbcee338-9d71-4370-bff2-08db4ce19dbc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4963 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the following feature bits. amd-psfd : Predictive Store Forwarding Disable: PSF is a hardware-based micro-architectural optimization designed to improve the performance of code execution by predicting address dependencies between loads and stores. While SSBD (Speculative Store Bypass Disable) disables both PSF and speculative store bypass, PSFD only disables PSF. PSFD may be desirable for the software which is concerned with the speculative behavior of PSF but desires a smaller performance impact than setting SSBD. Depends on the following kernel commit: b73a54321ad8 ("KVM: x86: Expose Predictive Store Forwarding Disable") stibp-always-on : Single Thread Indirect Branch Prediction mode has enhanced performance and may be left always on. The documentation for the features are available in the links below. a. Processor Programming Reference (PPR) for AMD Family 19h Model 01h, Revision B1 Processors b. SECURITY ANALYSIS OF AMD PREDICTIVE STORE FORWARDING Signed-off-by: Babu Moger Acked-by: Michael S. Tsirkin Link: https://www.amd.com/system/files/documents/security-analysis-predictive-store-forwarding.pdf Link: https://www.amd.com/system/files/TechDocs/55898_B1_pub_0.50.zip --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6c20ce86d1..1a79d224da 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -911,10 +911,10 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { NULL, NULL, NULL, NULL, NULL, "wbnoinvd", NULL, NULL, "ibpb", NULL, "ibrs", "amd-stibp", - NULL, NULL, NULL, NULL, + NULL, "stibp-always-on", NULL, NULL, NULL, NULL, NULL, NULL, "amd-ssbd", "virt-ssbd", "amd-no-ssb", NULL, - NULL, NULL, NULL, NULL, + "amd-psfd", NULL, NULL, NULL, }, .cpuid = { .eax = 0x80000008, .reg = R_EBX, }, .tcg_features = 0, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d243e290d3..14645e3cb8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -932,8 +932,12 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, #define CPUID_8000_0008_EBX_IBRS (1U << 14) /* Single Thread Indirect Branch Predictors */ #define CPUID_8000_0008_EBX_STIBP (1U << 15) +/* STIBP mode has enhanced performance and may be left always on */ +#define CPUID_8000_0008_EBX_STIBP_ALWAYS_ON (1U << 17) /* Speculative Store Bypass Disable */ #define CPUID_8000_0008_EBX_AMD_SSBD (1U << 24) +/* Predictive Store Forwarding Disable */ +#define CPUID_8000_0008_EBX_AMD_PSFD (1U << 28) #define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEC (1U << 1) From patchwork Thu May 4 20:53:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09B9CC7EE2D for ; Thu, 4 May 2023 20:55:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbjEDUzL (ORCPT ); Thu, 4 May 2023 16:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231184AbjEDUyx (ORCPT ); Thu, 4 May 2023 16:54:53 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20609.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::609]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0666E5FD7 for ; Thu, 4 May 2023 13:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EIoeZ0D6il5AURmWl1JhinW7X9Gl8bth6k6aaa/6m0hHRL7SDJGr/Du6g1Czw7Ie0//a61LvTfNrWex7C1luOFK/D/kto184EZyi+UtdLgM9ELUwatsPJ5Rtf8ePkTgEPseng3irhJkxsKvTzYDNSgwh/gCac/xRyjtIMgs6dcCpXLmn2yNYc7mbnFw68ex/EESXtGI4b/XMBaKJfHShzxHn1eTbIETxO7jkn7xwVEcS56zag5BIiNO4jjWAoZLHyD+yDGpyGe2D7VkhKcPJ6Y9OUT7yA5vqXuTfIjl0wzapXUCt/tG5VxD30X08AVrWEmVVex1+oF8ZE+49gGV7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rnZEhJAISTg6ODYqVysWyZFD73jAhHNQFTEEwqWkkII=; b=nVleNvxQOaIscG4Qj07PdkOMcIS5bHL5Rs5tz37NsV0JLD32WtjeXGWhPDG0+JbNaAUt1wG+8KSVf1wYcxG6NGb9IBlZbMKo0Z8pEwunL6gRXIyCy0Q+8igkYpxt8eZBIfjxi1NY3V1PShUaIZPHkHYFBWO4jt+VGMDBlAMnD7THVirL23r/NDX4ChLIPGECJTcMeBT6jZo7uzUFQ4gHBlJDlP5Hhw4It1ICgAJSQgaGYgBXzYHsKsBbO9RlusRKRufxfZppj8kAkLDaZWgKP8qj1Qe4W4XdeCzlzaLgBO4Qz+FInx7NV3Y36Rm+AMQlXAUa8IOg83B25E11NtJYyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rnZEhJAISTg6ODYqVysWyZFD73jAhHNQFTEEwqWkkII=; b=v98CJRGTVbV7JckIWgLxpOkcFuGVcxQe2VjgRorFnCrbH3v/JwekhiaxKV1Hf+adUfYvGoaSXVpsMfiU8WJ6NjX97S/9hS2jjdFxMIuyte4wLgNgouNI68lwMV6vPVqePYYpze/Pa3HoJMEB/m6oM0ZfnQI8Z0z7VdIGYk1Z6W0= Received: from MW4PR04CA0207.namprd04.prod.outlook.com (2603:10b6:303:86::32) by MN0PR12MB6368.namprd12.prod.outlook.com (2603:10b6:208:3d2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 20:53:31 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::5d) by MW4PR04CA0207.outlook.office365.com (2603:10b6:303:86::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.27 via Frontend Transport; Thu, 4 May 2023 20:53:30 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:27 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 4/7] target/i386: Add feature bits for CPUID_Fn80000021_EAX Date: Thu, 4 May 2023 15:53:09 -0500 Message-ID: <20230504205313.225073-5-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT046:EE_|MN0PR12MB6368:EE_ X-MS-Office365-Filtering-Correlation-Id: c0352203-2189-45d0-33fa-08db4ce19e5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yPNj5+hsiVTZMVhyJrv0GGKOTkUpPnFXt0Y+2neRtnxzLohIqJSaYZtvUJCUhsOaROWOChRpZY6OjSJOFh+0w0F/SSCxM7QCCa3hMnh66I/uX7f8PegyY4GSwMAokSAu+ebkIfoBg3lxcDOx+cwhbHkph42d5x3Lg5xwp6R7c3mZmrAEHrYdZOQPKJfQqygK/8qjMdAmrQEdcGMdj2ptCRnGlqvtY0/Eg5jsETvmzXyLCEBZxLUKaGlFYZ1cDIrApaiLxtnIuyXpeDXAshEwd1LoCP38tucbaqYjKIqnRWii56U9rj6/Q0ghfbUSHl9wVtFX9+Lzhsb4OVuS+IYxP7dBcSZ9ZcJAoU+I6XcFT5zXco/lMox4oalPsSn8UoLg9NN+BpQ/xuB1ZQtJQR8I5QZAbYIXquLeXj75HaSk1Ancq0//rMB7ud97lYxYm05UaAuTlBdnoLaxKYmeSktBy8Cqqfdl9LFZAbepeRfhwwOZRfCP7vyJJ2TDqZ8YhXjusZtrpxsbSFJCFk6iItjPNkIs+A1CJfD7vnF9O6WAe4EPZAoDrygRu+9EdGABHfUCJiZpbe9bfsiYsEIHYmlL6vo/FNDh6cRzjNHp1NUSBiVKId20P9f+pPr+jVOnnEgNiQ0faBeihQjcgOHFpN7xm4E6tf0zKiYdn5mQHBM+g6sCAtBnqZ6v7xEYJ4ik1IQc1Ap9Q3ZwSIpOUPz/DrGo41GPz7FX8m91CeJKIOFkV80G6u/MNgI5FLezFq8k8CrzqhOrmYWITlYWHq6yd3BDdg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199021)(40470700004)(36840700001)(46966006)(41300700001)(36860700001)(336012)(47076005)(426003)(316002)(8936002)(8676002)(5660300002)(2616005)(70206006)(4326008)(70586007)(7416002)(44832011)(2906002)(186003)(16526019)(82740400003)(356005)(40460700003)(26005)(1076003)(81166007)(7696005)(82310400005)(40480700001)(6666004)(54906003)(966005)(36756003)(86362001)(478600001)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:30.9468 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0352203-2189-45d0-33fa-08db4ce19e5b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6368 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the following feature bits. no-nested-data-bp : Processor ignores nested data breakpoints. lfence-always-serializing : LFENCE instruction is always serializing. null-sel-cls-base : Null Selector Clears Base. When this bit is set, a null segment load clears the segment base. The documentation for the features are available in the links below. a. Processor Programming Reference (PPR) for AMD Family 19h Model 01h, Revision B1 Processors b. AMD64 Architecture Programmer’s Manual Volumes 1–5 Publication No. Revision 40332 4.05 Date October 2022 Signed-off-by: Babu Moger Acked-by: Michael S. Tsirkin Link: https://www.amd.com/system/files/TechDocs/55898_B1_pub_0.50.zip Link: https://www.amd.com/system/files/TechDocs/40332_4.05.pdf --- target/i386/cpu.c | 24 ++++++++++++++++++++++++ target/i386/cpu.h | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1a79d224da..5c93c230e6 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -920,6 +920,22 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .tcg_features = 0, .unmigratable_flags = 0, }, + [FEAT_8000_0021_EAX] = { + .type = CPUID_FEATURE_WORD, + .feat_names = { + "no-nested-data-bp", NULL, "lfence-always-serializing", NULL, + NULL, NULL, "null-sel-clr-base", NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid = { .eax = 0x80000021, .reg = R_EAX, }, + .tcg_features = 0, + .unmigratable_flags = 0, + }, [FEAT_XSAVE] = { .type = CPUID_FEATURE_WORD, .feat_names = { @@ -6135,6 +6151,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ebx |= sev_get_reduced_phys_bits() << 6; } break; + case 0x80000021: + *eax = env->features[FEAT_8000_0021_EAX]; + *ebx = *ecx = *edx = 0; + break; default: /* reserved values: zero */ *eax = 0; @@ -6564,6 +6584,10 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp) x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F); } + if (env->features[FEAT_8000_0021_EAX]) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x80000021); + } + /* SGX requires CPUID[0x12] for EPC enumeration */ if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_SGX) { x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x12); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 14645e3cb8..7cf811d8fe 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -600,6 +600,7 @@ typedef enum FeatureWord { FEAT_8000_0001_ECX, /* CPUID[8000_0001].ECX */ FEAT_8000_0007_EDX, /* CPUID[8000_0007].EDX */ FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ + FEAT_8000_0021_EAX, /* CPUID[8000_0021].EAX */ FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ FEAT_KVM_HINTS, /* CPUID[4000_0001].EDX */ @@ -939,6 +940,13 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, /* Predictive Store Forwarding Disable */ #define CPUID_8000_0008_EBX_AMD_PSFD (1U << 28) +/* Processor ignores nested data breakpoints */ +#define CPUID_8000_0021_EAX_No_NESTED_DATA_BP (1U << 0) +/* LFENCE is always serializing */ +#define CPUID_8000_0021_EAX_LFENCE_ALWAYS_SERIALIZING (1U << 2) +/* Null Selector Clears Base */ +#define CPUID_8000_0021_EAX_NULL_SEL_CLR_BASE (1U << 6) + #define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEC (1U << 1) #define CPUID_XSAVE_XGETBV1 (1U << 2) From patchwork Thu May 4 20:53:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C8ABC7EE22 for ; Thu, 4 May 2023 20:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230506AbjEDUzP (ORCPT ); Thu, 4 May 2023 16:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbjEDUyt (ORCPT ); Thu, 4 May 2023 16:54:49 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1778138 for ; Thu, 4 May 2023 13:54:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QTEqDiaLUP6L93wX/udf/mLgozjTl/xZ4otcVjWbiPZhr90KA9n6AyDgq93Ii122SwDP2w+9Wpa6dXUwygmokIL+J+9ieehiBBQgcMK34nxTFR/5g7sOVc2Yq6nvnFN45m+p9jfp1CgHWwHvatDy+5Qq2kibfGL/oqcro4MZC9s3vtSuMdDgsB+G3tTYBtHafVbipz68OqV1Wsk9g7kIuUHvn3oEL71LzMVmNgJt2Roa1m0vUQFZHVQeeHlbyFfVBPxpTnN2G7ZNd/J40DqejFkKISyirHxDrIjvRG6xlKn0BY18OrVN43qUbvzi4tBXoW0NDiMMK4n/+0oflvaq2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rbWhGaDsfZ7f4Rtw53TegEa8G45rHiyejRm38z1ZK3E=; b=JgFsGOiNLMCLokoCqqkDdPwmoyXrWGAQPl2/WXFUPrqxDQ0WY5wGWF4Y3ysuViYXOnNtPpj0GmXVaP/ZLsFGcUKV7JsQk5rGJ6HrJu30zUKK9Qqbf2m5WhuXxGuBGPUlzgEAzbh0RoGKPuHLSuEAOAqcJNsXqyQM7YALMw9cNaQBELd+EvBzLNvrNXsRBaaPs4diSgqYGDGxSfkptKMtJ7CbP9t3AAOP/iTtA7f5NimWvqCUrRp88MQObtqJ7arm/3+EQZv5ydT8JTWz4ZT3t7pZgvwG4G0ya64zxiNOuGwwC1PJUkihwUCXema4ul+CRfeS+91RFIVbdXxW5P5wkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rbWhGaDsfZ7f4Rtw53TegEa8G45rHiyejRm38z1ZK3E=; b=pK0ZFFc5qn3z7wW4pLkfUWro4JsvRpC4V+8u0D0aR2/1ZB50t6g1bfDexCV/COO64GINlBo/E0atCrmxvhXGPsVjFNVVQa640uWZemSl25TbDj+Pu8M5e81nlRRiGKBj4YQD+hlId/7Jw7YUlO3B+vgRnX5Bwuaw8yt7UQHuV7U= Received: from MW4P222CA0011.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::16) by PH0PR12MB7470.namprd12.prod.outlook.com (2603:10b6:510:1e9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 20:53:31 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::6c) by MW4P222CA0011.outlook.office365.com (2603:10b6:303:114::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:30 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:28 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 5/7] target/i386: Add missing feature bits in EPYC-Milan model Date: Thu, 4 May 2023 15:53:10 -0500 Message-ID: <20230504205313.225073-6-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|PH0PR12MB7470:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c58fd64-e597-497c-a17b-08db4ce19e63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mM3B3IS/dYHTkEQwWQ40sFer8tudBGO1mo7IlLKgIwcAGVp2VeeA1oEvgR2RQTZbjVbrtM+SZCCwJOmNMWtpxOOxjTk9e5I8xZBAPV5QYT0nhPFfB6zAJM93RKMHpIawYojUhDgTr9XnD81wo4Jrf8B7ezVMwaOwyHK2zZLb9PawF1osmAtasHyI3lmJaKeTAlR7J5oF2XjmvvWAB8CQzUSPwn27WMfShEuvXOCLu4ttJGWW3D9xohaKCN9M71GCAHPPJiWzsCPbhZC/Er+XGZ7Cn04alTiPgHnzifLBkwIPM4rFOpEhvm8O21heRtVNfdtkNvY+PA3vDqju/qMGuWsi0uWyf+6N+GOoEXwgnRc/VeXj1juWBBjLLr4KxKGxV6hiypKeIQu6jPU8HP+I3jZlET4V9NuUJhnS1Pv+1GequwekL7ycMoc8+CZqrpocY8BKwbGmSTKkCuJ16Ap274pFSU7SKu1c7Y7J6/RXq6KMFSoLRQJUxgXe0pyhMre/epDzviHG+BQNspHlWlv0C+1dEt8vgjQ4Fq7axhxsYi89EW5VW0FpQ3SSmQ/nECjd1CSMBpgZN9wzSIKmLS0ajOkowRJ+z5uUTvvPkmSzwvxbRuzfPSX9fc5r/h+7HhMffHat6hERAYEaTZ3BVXXpTTdyHKANFpeYrqjcyrhcajrXFOxCz4ersH5ggZ/B8v2aj6Ut437EnNuoSmml+1Zz27jqCE6Pj7qM3VwA6v2CfigxnRGwvw+u4fbbJN4U2RllFDhToCIyG9ZB1xyvwSFMaA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(478600001)(4326008)(70206006)(7696005)(70586007)(6666004)(966005)(54906003)(316002)(110136005)(86362001)(36756003)(426003)(47076005)(336012)(26005)(36860700001)(1076003)(8676002)(8936002)(7416002)(5660300002)(44832011)(41300700001)(2906002)(82310400005)(40480700001)(356005)(81166007)(16526019)(186003)(83380400001)(2616005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:30.9864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c58fd64-e597-497c-a17b-08db4ce19e63 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7470 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the following feature bits for EPYC-Milan model and bump the version. vaes : Vector VAES(ENC|DEC), VAES(ENC|DEC)LAST instruction support vpclmulqdq : Vector VPCLMULQDQ instruction support stibp-always-on : Single Thread Indirect Branch Prediction Mode has enhanced performance and may be left Always on amd-psfd : Predictive Store Forward Disable no-nested-data-bp : Processor ignores nested data breakpoints lfence-always-serializing : LFENCE instruction is always serializing null-sel-clr-base : Null Selector Clears Base. When this bit is set, a null segment load clears the segment base These new features will be added in EPYC-Milan-v2. The "-cpu help" output after the change will be. x86 EPYC-Milan (alias configured by machine type) x86 EPYC-Milan-v1 AMD EPYC-Milan Processor x86 EPYC-Milan-v2 AMD EPYC-Milan Processor The documentation for the features are available in the links below. a. Processor Programming Reference (PPR) for AMD Family 19h Model 01h, Revision B1 Processors b. SECURITY ANALYSIS OF AMD PREDICTIVE STORE FORWARDING c. AMD64 Architecture Programmer’s Manual Volumes 1–5 Publication No. Revision 40332 4.05 Date October 2022 Signed-off-by: Babu Moger Acked-by: Michael S. Tsirkin Link: https://www.amd.com/system/files/TechDocs/55898_B1_pub_0.50.zip Link: https://www.amd.com/system/files/documents/security-analysis-predictive-store-forwarding.pdf Link: https://www.amd.com/system/files/TechDocs/40332_4.05.pdf --- target/i386/cpu.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5c93c230e6..0a6fb2fc82 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1923,6 +1923,56 @@ static const CPUCaches epyc_milan_cache_info = { }, }; +static const CPUCaches epyc_milan_v2_cache_info = { + .l1d_cache = &(CPUCacheInfo) { + .type = DATA_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l1i_cache = &(CPUCacheInfo) { + .type = INSTRUCTION_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l2_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 2, + .size = 512 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 1024, + .lines_per_tag = 1, + }, + .l3_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 3, + .size = 32 * MiB, + .line_size = 64, + .associativity = 16, + .partitions = 1, + .sets = 32768, + .lines_per_tag = 1, + .self_init = true, + .inclusive = true, + .complex_indexing = false, + }, +}; + /* The following VMX features are not supported by KVM and are left out in the * CPU definitions: * @@ -4401,6 +4451,26 @@ static const X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x8000001E, .model_id = "AMD EPYC-Milan Processor", .cache_info = &epyc_milan_cache_info, + .versions = (X86CPUVersionDefinition[]) { + { .version = 1 }, + { + .version = 2, + .props = (PropValue[]) { + { "model-id", + "AMD EPYC-Milan-v2 Processor" }, + { "vaes", "on" }, + { "vpclmulqdq", "on" }, + { "stibp-always-on", "on" }, + { "amd-psfd", "on" }, + { "no-nested-data-bp", "on" }, + { "lfence-always-serializing", "on" }, + { "null-sel-clr-base", "on" }, + { /* end of list */ } + }, + .cache_info = &epyc_milan_v2_cache_info + }, + { /* end of list */ } + } }, }; From patchwork Thu May 4 20:53:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F1A9C7EE22 for ; Thu, 4 May 2023 20:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbjEDUzK (ORCPT ); Thu, 4 May 2023 16:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbjEDUyx (ORCPT ); Thu, 4 May 2023 16:54:53 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9B799EEE for ; Thu, 4 May 2023 13:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j74N8s2BARecRM4Z/EGTkbImoJvGa654hAPxT8hvz1BS2S6dKtcgAyDnRAYq4oCVv4JQJ3lAxqIS0r06ihp9F+PvmxXRgAHwpK2iAc5DUFE0RYMTBx5TKcX1JUCAOuTT7uZrJt7AzWOqtplDBRuYyn9C2FJubR7DIYszpdspvNOLpReMgEtdaaqke9YOACXYJTU18dkezL0JI+xutrU5zC/H31zUB/nOly/tTbtVMs6OflR9NkW/vGTWIEWR/TS9L7VBMC3WpLBirvDMA0MpYMCXi+PzS18Flcx0sDIVxevNydKugjb6rcWA+n1qvCfUerdgZ19ItG2bDxBG7ZgrLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9hp2/tJWr7a7IUBgGdrJraven/9x9JRPhj+y1L5oiqI=; b=Y6FEKHhekwrB606kNXId3fUU+GTtvJzbGcpIXd/MpjDSJ+AA8DfflyrXnvgjfUsc0jpDimIeKbIGDF/MiDoXpE5CILm/mxiwj9xkO10UOK8iQfkyAm7m/QMy3Gtw6J1e9V/fc/u4hMpVB90IXKkxCiGvI+R3tnx8XGPxQ+dgdBZU7Pqdg//okksMVeL76DiEmAl8CJMKqyja1kU/bER7xH6w+FPWU2ZUGd/RGM1DHgg8HKV8i3GPYIM5NJy9bIdDPb2cND9VVSyz91/1e3wiy9NK+fH6iOnqlJX7J2TbnUAsiJStVewyqYFZui2qB1yrE3M6ZtRtEYOHvbF44c5W9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9hp2/tJWr7a7IUBgGdrJraven/9x9JRPhj+y1L5oiqI=; b=374MoYwbRXh/9Yk0EgfBt7OhAJ6gPxaSTD8ZVMye5GoPNTTLOkFp43qjxj0RhWwiBYEATfh1OXUWyf0A3f9bFGn1kRXLATkgcPaCrL8qRC1Qg5+OLg5D/mnebiDBaNQSiSMK1mvbSyoyvQmotZSumB1MyWlSiKNYuhMkPpwyXAk= Received: from MW4P222CA0014.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::19) by PH7PR12MB7306.namprd12.prod.outlook.com (2603:10b6:510:20a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.20; Thu, 4 May 2023 20:53:31 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::da) by MW4P222CA0014.outlook.office365.com (2603:10b6:303:114::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:31 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:29 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 6/7] target/i386: Add VNMI and automatic IBRS feature bits Date: Thu, 4 May 2023 15:53:11 -0500 Message-ID: <20230504205313.225073-7-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|PH7PR12MB7306:EE_ X-MS-Office365-Filtering-Correlation-Id: c27fdc1b-c059-48e2-9b88-08db4ce19ec0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KpLsU8Pj741D7pfdOPAASpLZ21iU94ttyjGdczuNgIygA/l/iUzacjjca8JvSJ9m7LAiAPz6gKlTAik4o749bOu3QGSMzfGfSf2e4ZE1rMZu/DL7KSAx0OOxeKAkxpcSDCLLaEfUDeANXTUfbrLa7lBCABARjJPOTD+45Xjww5tgl3lCjGpQvXzLVBVl8RUKD/Q1/teEcr4BjVcboslcgHzkjtLOpQGOFKxXfwZdZylh3Sj1eA6EBy+wDG/Gw3TFDnKCoRovAoot9HLUhrGXgr4dD3kwAGOHpYg8XH76tGF/27ejQIZtJI2WUjnVJAtPb6R9b7+tnC3FVN3pGR+uLE9zU/ZzOrbo5NkQElgo1jAPQqtdpz5AR8txCRgdzYHQntc/sHhFrAj+qFu8nwMLvopHXMi1m2ymSkQ0eAj1lFh6Nl9p2F45WV1TEkip1NQ5pFfQYz7NKx+NIOrE4jAc3DZoh6IsZGZ5sU1upM4bLI0PRGDcMp9cTKlRJVYC8vgUtn1MNH80+W5HMX7BjNxsZ92VLf2B5TNeUPXt25a0lt4V37WdjEUu0nPFC5DhaJYkvUwrhCrUqKtuRkVxsv/p4QzTAfUlY6euN7Zr7S0eelQ/vLqn6t9SRidYWKPJpI/6ZwPiK3DirYu1vLFGMZRFY/6LCbZvJUb4TTG5ML5m9Ij002MHrldscL0PB7olTX2jcUPgQXysnF7lVGfYYiKF5BHUrZuf+YmLfnxuo0sQiQ4xmXCKBCAkv1Fk3tA1960gXJsMc/OB5zPKAW5CRWX05A== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199021)(46966006)(40470700004)(36840700001)(478600001)(186003)(36756003)(16526019)(54906003)(2616005)(82310400005)(7696005)(966005)(4326008)(36860700001)(47076005)(6666004)(316002)(110136005)(1076003)(26005)(336012)(70586007)(83380400001)(426003)(70206006)(8936002)(41300700001)(2906002)(5660300002)(8676002)(356005)(82740400003)(7416002)(44832011)(40460700003)(40480700001)(86362001)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:31.6113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c27fdc1b-c059-48e2-9b88-08db4ce19ec0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7306 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the following featute bits. vnmi: Virtual NMI (VNMI) allows the hypervisor to inject the NMI into the guest without using Event Injection mechanism meaning not required to track the guest NMI and intercepting the IRET. The presence of this feature is indicated via the CPUID function 0x8000000A_EDX[25]. automatic-ibrs : The AMD Zen4 core supports a new feature called Automatic IBRS. It is a "set-and-forget" feature that means that, unlike e.g., s/w-toggled SPEC_CTRL.IBRS, h/w manages its IBRS mitigation resources automatically across CPL transitions. The presence of this feature is indicated via the CPUID function 0x80000021_EAX[8]. The documention for the features are available in the links below. a. Processor Programming Reference (PPR) for AMD Family 19h Model 01h, Revision B1 Processors b. AMD64 Architecture Programmer’s Manual Volumes 1–5 Publication No. Revision 40332 4.05 Date October 2022 Signed-off-by: Santosh Shukla Signed-off-by: Kim Phillips Signed-off-by: Babu Moger Link: https://www.amd.com/system/files/TechDocs/55898_B1_pub_0.50.zip Link: https://www.amd.com/system/files/TechDocs/40332_4.05.pdf --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0a6fb2fc82..d50ace84bf 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -806,7 +806,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { "pfthreshold", "avic", NULL, "v-vmsave-vmload", "vgif", NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, + NULL, "vnmi", NULL, NULL, "svme-addr-chk", NULL, NULL, NULL, }, .cpuid = { .eax = 0x8000000A, .reg = R_EDX, }, @@ -925,7 +925,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .feat_names = { "no-nested-data-bp", NULL, "lfence-always-serializing", NULL, NULL, NULL, "null-sel-clr-base", NULL, - NULL, NULL, NULL, NULL, + "auto-ibrs", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 7cf811d8fe..f6575f1f01 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -773,6 +773,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, #define CPUID_SVM_AVIC (1U << 13) #define CPUID_SVM_V_VMSAVE_VMLOAD (1U << 15) #define CPUID_SVM_VGIF (1U << 16) +#define CPUID_SVM_VNMI (1U << 25) #define CPUID_SVM_SVME_ADDR_CHK (1U << 28) /* Support RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */ @@ -946,6 +947,8 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, #define CPUID_8000_0021_EAX_LFENCE_ALWAYS_SERIALIZING (1U << 2) /* Null Selector Clears Base */ #define CPUID_8000_0021_EAX_NULL_SEL_CLR_BASE (1U << 6) +/* Automatic IBRS */ +#define CPUID_8000_0021_EAX_AUTO_IBRS (1U << 8) #define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEC (1U << 1) From patchwork Thu May 4 20:53:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 13231795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02781C77B73 for ; Thu, 4 May 2023 20:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbjEDUzJ (ORCPT ); Thu, 4 May 2023 16:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbjEDUyt (ORCPT ); Thu, 4 May 2023 16:54:49 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::61b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DE35B1 for ; Thu, 4 May 2023 13:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLDyMtfSC09kGEieg1uRm9VYIOphjR923sXkpLRGPUuM0Lw0ZYhCaVixeNMARjTaeyKY8Yzwvtd/xDsHywk3lvSwEcjU5ZM7n2W5jLwV3JnZBaZLBJhQS4B8k9hvUBjZQSJLhNdTY6aqcjwmqC3sAEEPU44D+pm3fA4q4azIsOaw4wwyG4OHb4DP4LyWOZhFEpEi99z2N0TsY9zo4apDbr1xRovNfKrUTD9yPsy9Psh8sGQ4rqZ8C5BRsdbmpC0DWdVYA/9NDc2KCk62U7aakhjWnIpogSPHk0rXjhhcDceEX7Bikf4RMX8G5Z7Pckh7YBe3wH8slEpVZx6B4qiVfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YlHpPkuppVHlDMATPAqeYcJ2Kr09C0OxfBnDZdoE/ew=; b=f6soLSczfvcFRZpIg8gSdoJkYOadMs2M5OhytuXEcuwtvavhz9pjILzMRy0h5EYM287AD6N9fJ1ikJkm94u8X97CwaW2Ho5lIWzRNUAFXQv7eZIlzw8OOHlrisMMpRI3oEqTR/LCC+6wcoOWfhneYe/XaC2BrSUkOmf1hOxuV0dRs8TeSdnuhoA9U5o7L8hP6ULGS3znbVxCZ2vGSwhTtZ4W+k2o4PiUnGTO+bHt+Lu/V3jNOWaqzfbiTiSZ/tQsPLjZeAHtC024MaVIQc8JkjtHaIvP7t6D33kez11OD5K1moQL/d3TADwm/FgbBtmoxpGunD/bssvzlQ0oWxEnHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YlHpPkuppVHlDMATPAqeYcJ2Kr09C0OxfBnDZdoE/ew=; b=SwWC9RE65gPxuXsxMxx5Kwtd8tyqYkTQpKjbdyyokPLeLEUrkJaCbNYI8Ak5fU1F9vCbYf3vumSMFxAFVFobVI0Y9+bwkcslLr7G7UdGRiqKLCzuLxbWw3rkJIEwN9FmJOtnhAujDRJef64cJVFsS+WRyTyedUW8vfIpUp5WWVA= Received: from MW4PR04CA0198.namprd04.prod.outlook.com (2603:10b6:303:86::23) by MN2PR12MB4423.namprd12.prod.outlook.com (2603:10b6:208:24f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 20:53:32 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::7a) by MW4PR04CA0198.outlook.office365.com (2603:10b6:303:86::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26 via Frontend Transport; Thu, 4 May 2023 20:53:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.27 via Frontend Transport; Thu, 4 May 2023 20:53:31 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 4 May 2023 15:53:30 -0500 From: Babu Moger To: , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v4 7/7] target/i386: Add EPYC-Genoa model to support Zen 4 processor series Date: Thu, 4 May 2023 15:53:12 -0500 Message-ID: <20230504205313.225073-8-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230504205313.225073-1-babu.moger@amd.com> References: <20230504205313.225073-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT046:EE_|MN2PR12MB4423:EE_ X-MS-Office365-Filtering-Correlation-Id: 24e24c36-ed0c-4fbd-c9b9-08db4ce19ed4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GJ/4yIdlH21nkrVVDVEF/+gh/krLJzajldqimztiLDagtamb5A9dgboh4vM4Oqbtt2fH6J55j+v7qNkiDoI1MUVXcJt3n/Pj4oq+cHcfRcWUUL3ROJ+/lsuIS/GmtYdhMGxqwcVkfMkJXfcOOYDeWMgTRT7aQcg6oi6bHYLOl89qvVNnBGV2S8njh5G9XClju67QEB06caE8RgWdhGhn6VpIRlWTgQ3I3RJhYPwleHhM1CbgC9y9MUS1BLcPPuqAjEPZNqAzzSeO9NRNbUvj84Ex0jH0rXXKwrX/so9yJFWo4eFuKSOTxOImoBDB/6DySgk7xR7lpcgxAPQeTuht1tw6KnqQlHVTsosV/PIOE7QM1Dhinl+zxx1/WDC60rdevD8e55Ord6Za4r4P8a9BiqJpHF4xmufsyLIXmGU3y56uVkMbLlyyedDEFmz7vlQgVcFZ6sEdVT1WRKWZQ/RnpKJNiEFydahR9pve1+bNMwlwa6QttUHPvJU8dYQbsYY1IoOeJI5CLmMazeq5xs4pL2oXDe6JS8UBMJc9cdnO11z18dLuJSk5khT+37IJ47sexVodN+IL08URK0TfKBAKJ9JdKuJ89Hj0IRkXkHu5DaxmDW5k0pZyburHde8EvkyZq9xIW0vThExjJrdAMBOMUFJy374zKIxm9vO5kZqoTsmMqJ9zsA6jvHWfV6pRAb+SJxHuJWew4bgpivTCujfSXrkrenInjepNAJfJxayxysg= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199021)(40470700004)(46966006)(36840700001)(36756003)(47076005)(86362001)(70586007)(54906003)(7696005)(70206006)(6666004)(110136005)(4326008)(478600001)(316002)(82310400005)(40480700001)(5660300002)(2906002)(44832011)(8936002)(7416002)(16526019)(82740400003)(8676002)(356005)(81166007)(186003)(2616005)(1076003)(26005)(41300700001)(36860700001)(426003)(336012)(83380400001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 20:53:31.7436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24e24c36-ed0c-4fbd-c9b9-08db4ce19ed4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4423 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Adds the support for AMD EPYC Genoa generation processors. The model display for the new processor will be EPYC-Genoa. Adds the following new feature bits on top of the feature bits from the previous generation EPYC models. avx512f : AVX-512 Foundation instruction avx512dq : AVX-512 Doubleword & Quadword Instruction avx512ifma : AVX-512 Integer Fused Multiply Add instruction avx512cd : AVX-512 Conflict Detection instruction avx512bw : AVX-512 Byte and Word Instructions avx512vl : AVX-512 Vector Length Extension Instructions avx512vbmi : AVX-512 Vector Byte Manipulation Instruction avx512_vbmi2 : AVX-512 Additional Vector Byte Manipulation Instruction gfni : AVX-512 Galois Field New Instructions avx512_vnni : AVX-512 Vector Neural Network Instructions avx512_bitalg : AVX-512 Bit Algorithms, add bit algorithms Instructions avx512_vpopcntdq: AVX-512 AVX-512 Vector Population Count Doubleword and Quadword Instructions avx512_bf16 : AVX-512 BFLOAT16 instructions la57 : 57-bit virtual address support (5-level Page Tables) vnmi : Virtual NMI (VNMI) allows the hypervisor to inject the NMI into the guest without using Event Injection mechanism meaning not required to track the guest NMI and intercepting the IRET. auto-ibrs : The AMD Zen4 core supports a new feature called Automatic IBRS. It is a "set-and-forget" feature that means that, unlike e.g., s/w-toggled SPEC_CTRL.IBRS, h/w manages its IBRS mitigation resources automatically across CPL transitions. Signed-off-by: Babu Moger --- target/i386/cpu.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d50ace84bf..71fe1e02ee 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1973,6 +1973,56 @@ static const CPUCaches epyc_milan_v2_cache_info = { }, }; +static const CPUCaches epyc_genoa_cache_info = { + .l1d_cache = &(CPUCacheInfo) { + .type = DATA_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l1i_cache = &(CPUCacheInfo) { + .type = INSTRUCTION_CACHE, + .level = 1, + .size = 32 * KiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 64, + .lines_per_tag = 1, + .self_init = 1, + .no_invd_sharing = true, + }, + .l2_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 2, + .size = 1 * MiB, + .line_size = 64, + .associativity = 8, + .partitions = 1, + .sets = 2048, + .lines_per_tag = 1, + }, + .l3_cache = &(CPUCacheInfo) { + .type = UNIFIED_CACHE, + .level = 3, + .size = 32 * MiB, + .line_size = 64, + .associativity = 16, + .partitions = 1, + .sets = 32768, + .lines_per_tag = 1, + .self_init = true, + .inclusive = true, + .complex_indexing = false, + }, +}; + /* The following VMX features are not supported by KVM and are left out in the * CPU definitions: * @@ -4472,6 +4522,78 @@ static const X86CPUDefinition builtin_x86_defs[] = { { /* end of list */ } } }, + { + .name = "EPYC-Genoa", + .level = 0xd, + .vendor = CPUID_VENDOR_AMD, + .family = 25, + .model = 17, + .stepping = 0, + .features[FEAT_1_EDX] = + CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUSH | + CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE | + CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE | + CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE | + CPUID_VME | CPUID_FP87, + .features[FEAT_1_ECX] = + CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX | + CPUID_EXT_XSAVE | CPUID_EXT_AES | CPUID_EXT_POPCNT | + CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | + CPUID_EXT_PCID | CPUID_EXT_CX16 | CPUID_EXT_FMA | + CPUID_EXT_SSSE3 | CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | + CPUID_EXT_SSE3, + .features[FEAT_8000_0001_EDX] = + CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB | + CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX] = + CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH | + CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | + CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM | + CPUID_EXT3_TOPOEXT | CPUID_EXT3_PERFCORE, + .features[FEAT_8000_0008_EBX] = + CPUID_8000_0008_EBX_CLZERO | CPUID_8000_0008_EBX_XSAVEERPTR | + CPUID_8000_0008_EBX_WBNOINVD | CPUID_8000_0008_EBX_IBPB | + CPUID_8000_0008_EBX_IBRS | CPUID_8000_0008_EBX_STIBP | + CPUID_8000_0008_EBX_STIBP_ALWAYS_ON | + CPUID_8000_0008_EBX_AMD_SSBD | CPUID_8000_0008_EBX_AMD_PSFD, + .features[FEAT_8000_0021_EAX] = + CPUID_8000_0021_EAX_No_NESTED_DATA_BP | + CPUID_8000_0021_EAX_LFENCE_ALWAYS_SERIALIZING | + CPUID_8000_0021_EAX_NULL_SEL_CLR_BASE | + CPUID_8000_0021_EAX_AUTO_IBRS, + .features[FEAT_7_0_EBX] = + CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 | + CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | + CPUID_7_0_EBX_INVPCID | CPUID_7_0_EBX_AVX512F | + CPUID_7_0_EBX_AVX512DQ | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | + CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_AVX512IFMA | + CPUID_7_0_EBX_CLFLUSHOPT | CPUID_7_0_EBX_CLWB | + CPUID_7_0_EBX_AVX512CD | CPUID_7_0_EBX_SHA_NI | + CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512VL, + .features[FEAT_7_0_ECX] = + CPUID_7_0_ECX_AVX512_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU | + CPUID_7_0_ECX_AVX512_VBMI2 | CPUID_7_0_ECX_GFNI | + CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ | + CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG | + CPUID_7_0_ECX_AVX512_VPOPCNTDQ | CPUID_7_0_ECX_LA57 | + CPUID_7_0_ECX_RDPID, + .features[FEAT_7_0_EDX] = + CPUID_7_0_EDX_FSRM, + .features[FEAT_7_1_EAX] = + CPUID_7_1_EAX_AVX512_BF16, + .features[FEAT_XSAVE] = + CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1 | CPUID_XSAVE_XSAVES, + .features[FEAT_6_EAX] = + CPUID_6_EAX_ARAT, + .features[FEAT_SVM] = + CPUID_SVM_NPT | CPUID_SVM_NRIPSAVE | CPUID_SVM_VNMI | + CPUID_SVM_SVME_ADDR_CHK, + .xlevel = 0x80000022, + .model_id = "AMD EPYC-Genoa Processor", + .cache_info = &epyc_genoa_cache_info, + }, }; /*