From patchwork Wed Feb 28 21:10:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10249881 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 E431460362 for ; Wed, 28 Feb 2018 21:39:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF5AF286F4 for ; Wed, 28 Feb 2018 21:39:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C02ED28D48; Wed, 28 Feb 2018 21:39:06 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8EC50286F4 for ; Wed, 28 Feb 2018 21:39:04 +0000 (UTC) Received: from localhost ([::1]:47115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er9RH-0007sO-RV for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 16:39:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er90W-0001Xm-Fx for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:11:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er90S-00066U-BX for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:11:24 -0500 Received: from mail-dm3nam03on0060.outbound.protection.outlook.com ([104.47.41.60]:17929 helo=NAM03-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1er90S-00064W-2C for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:11:20 -0500 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=vqV0+918XIPD/xtA91ylkG0s4V/sQ6qxC33YuQjqIc8=; b=HmTOcAzDNyS3o/YoHln7c0vQymuXEEzDOGdolCFNhUaeNPgybwILj+8yDJECoy+Pns/X8Ny8ciVJg5SOnhoLnVQBvkQrvRKGQ5Mvh7N2HnnFmMAzcdzN8duvhVoBKwNimvRlwvpvn+jlNg+JDK7wXGRPdBNUA8F91nkt1FAaNpk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.15; Wed, 28 Feb 2018 21:11:17 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 15:10:25 -0600 Message-Id: <20180228211028.83970-26-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180228211028.83970-1-brijesh.singh@amd.com> References: <20180228211028.83970-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM5PR10CA0008.namprd10.prod.outlook.com (2603:10b6:4:2::18) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c62f61d1-9477-4871-f9b4-08d57eefcf12 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:DYf79Af5YRi2uMwOWYUF3y/JROjU3NVw1f985qHpxOOfl8BgWqv6e/MAQ+S7YfyW12oFYGlHP2AtougisURcaGmB+ok3du0IHriaobv1kpk2z0Kkcy0L8FYQp6rwaBqvBD+TBKPrZffHrhX3/dWKteEaEEHqieEiXMRQn/y4Kr/FreFRVivYTEGBb8eocqudcdlNVgpMQw/Fef5RCdey4/ppwfZ0w3o5MTZD6w4uUDZo2/bjdVM1GBhknXpAxYuF; 25:/+0E8K8NS+67Q8JJhGhoJzVE0nTYeGNbVAK2o588hjmjkpfxES804KJ5j9x6Mgo4itAVPm4dCugxvww3hC6yv9zofuwfqq2W62xrJfG8xmWSBL8ZdW6KMkSW1JoTBjcnFREBvZ5vSxssT9UODzQV5EDRT1ZcGjrhWHWXuCX2GHDEl1gixz+wAAnhJHFYy12NLE3Xw/ydmF9uoxqFywmkFkSH+CKOSWkNnfMC0g93UnfDcUWE5RJfYSbHuo/LsfHr1U8/DX2tHWUU3wEtl05BSAgU1FiUqJld4duOveczimBuFIVaWmxBBeGoal+FYWh2/0ERLjaZmWPro5luTsbxzw==; 31:CFNYZr4wXREJVYkwpoYko/7SUEuiSEMLQqOj8OBM4oOyCKTcM3BaORBiA4l1rdX0M5rOZEyp77M7Z2ytCnED2cOkdx9I5WsrWzNDGjtuzaApps748z1EPTGi/Gx0nsu0clHHjMPtquArtMu4ZRvvfnbwNGSFxuEhQpMypNUihLf49Vc6ceTfARFMXk6AwpsstFyZn9+5pBhMbBSYRh41JVXh/+tqZgVEu21OcUkZoxk= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:jjh9AP/uMrs2Q0nrXLISvW1sgXjQx6dRfW3MGuG2XW7ao+FgXjZ3iKbZlqqduFbjwbB2qI0/AfncsPMbzZGiCcwI5oohjfaN5l6bDKUkkZkSZ8wNVHw4Ege/TRf75xVO1X6LpDJvh0uR/lNSFtRTNMGEnh0wUX6uXVb54sk0z5K6tpbvttFLVBsqWFkynVHg1CNxIVOZkFu1Mv3+nzILYPo4mlr6WQ6RrdtHPQVpz/mqbdIms4SVtKxvDxmMqX3Y464qvB7StNz9xf6n12FVDa5JDgI6MQ4RHbHvNc7C2O88GU0YUyWNUqZC9FiVqkoenEfxQJM+PzYN/6Rioxni2uc2F6i6xiydyR7J8YIjmvUWz+Nou2Xq9zqUaPlT5qu3HcS+/p/pMeLBST2gep8NTB2Wc6V8t7OrokgxqL9PEX9up+pZy42OFGWQozHOU6PJZeFDy/qGpiBa4IyNkO84Owf2Z7YTBNHSzIQF1Aiv1T9LfzrlQbPPHouFCGMbv/Yu; 4:qpHg4qF7U9x9jJlX6Xyjem17lF3GLEKLHCOQxvQhRGNLYeY98yo+oIkCDgBxKK8M36CR3Ldjh5e1OcA2FzNnDuq1kZvkUtSX9/uUgviCnq1pgngQ4lx8P8RixM80MW3h9mPbzwbymazgWhVT7XYFscswx+VknDs7jUdxEPXSueqwrsCwM4Wg9xezyjd8MZLry+zoSpH8qk1ykzX96X3dopKv1Y6x/8gvD2JduHKq63LEC6j1q68TdpXhStfMaMwMSrb5WLkky2+GEvO9BJ52+sSnofO8A3kYNMu/GaACIXpyaLi+HCyOpsIBDdpW4xxT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(3231220)(944501219)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0155; X-Forefront-PRVS: 0597911EE1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39860400002)(39380400002)(396003)(346002)(366004)(376002)(189003)(199004)(6486002)(6116002)(1076002)(2351001)(36756003)(16526019)(16586007)(54906003)(53416004)(26005)(53936002)(66066001)(186003)(47776003)(6306002)(59450400001)(2361001)(478600001)(8666007)(316002)(81166006)(50226002)(8676002)(8936002)(386003)(106356001)(97736004)(5660300001)(2950100002)(6666003)(305945005)(4326008)(76176011)(7736002)(39060400002)(8656006)(105586002)(68736007)(50466002)(7696005)(51416003)(25786009)(48376002)(52116002)(3846002)(2906002)(86362001)(81156014)(7416002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:wsp141597wss.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:AZ07pBF3+P+i+YJjBQBHd6yr5J37YMBkLlKrAGZc0?= =?us-ascii?Q?K4JdGOpL+YoEXEEq5b3PWJlLzSneDkzeOVGPtWGbUW015hLXzq1sEXlgpPrr?= =?us-ascii?Q?3J92uSB0tO0tSBnL2oE2XAB3cnBXYguiHvxgYnJtFEr5BYl8H+tO+dmv5k32?= =?us-ascii?Q?5d1QZX6lh7j+s6Gc+2ApF44wCCKHE3x2/9DhZECNA5DEgtlsd7LFcoc5Ir12?= =?us-ascii?Q?YkFE8SCLHN+dz5dv2ah5KPdwUWgMrrlcmVksDFruY898l5QgAx1Nep5JKLOF?= =?us-ascii?Q?0iZpeZ6ciHPnuDmquD6WXidGBtDIgvTIvm9Xzi4DJOZ0k6vT3Cn/IZHq2o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CLSWomcxGSRgQPIs5v SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:yvRpLqPgR4O9qvZF3Xb6IdD4VsbIiJmMSrE/tlZinZBi/PS9y2CRX7gx+9sGjfkhY/6NNoq8kRMeqpnRTJMc9rht83o1dAzq1IeaR7QySMJjZwi28W1xOSqx7RAr1SXnN1epj2oIhbUysDR/zJXjcu1xo2i7DCUQUOCZExZilcEMFuvyA7RNFaqUz1HxISCBvXE6+E194goh1KoJH1Wdmj4k+99iaO+9JfvevC544S0F2WvpIRyBYwhcbbO/5u7Y X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2018 21:11:17.1079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c62f61d1-9477-4871-f9b4-08d57eefcf12 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.41.60 Subject: [Qemu-devel] [PATCH v10 25/28] cpu/i386: populate CPUID 0x8000_001F when SEV is active X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Brijesh Singh , kvm@vger.kernel.org, "Michael S. Tsirkin" , Stefan Hajnoczi , Alexander Graf , "Edgar E. Iglesias" , Markus Armbruster , Bruce Rogers , Christian Borntraeger , Marcel Apfelbaum , Borislav Petkov , Thomas Lendacky , Eduardo Habkost , Richard Henderson , "Dr. David Alan Gilbert" , Alistair Francis , Cornelia Huck , Richard Henderson , Peter Crosthwaite , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When SEV is enabled, CPUID 0x8000_001F should provide additional information regarding the feature (such as which page table bit is used to mark the pages as encrypted etc). The details for memory encryption CPUID is available in AMD APM (https://support.amd.com/TechDocs/24594.pdf) Section E.4.17 Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Signed-off-by: Brijesh Singh Reviewed-by: Eduardo Habkost --- target/i386/cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b5e431e769da..7a3cec59402b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -26,6 +26,7 @@ #include "sysemu/hvf.h" #include "sysemu/cpus.h" #include "kvm_i386.h" +#include "sev_i386.h" #include "qemu/error-report.h" #include "qemu/option.h" @@ -3612,6 +3613,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx = 0; *edx = 0; break; + case 0x8000001F: + *eax = sev_enabled() ? 0x2 : 0; + *ebx = sev_get_cbit_position(); + *ebx |= sev_get_reduced_phys_bits() << 6; + *ecx = 0; + *edx = 0; + break; default: /* reserved values: zero */ *eax = 0; @@ -4041,6 +4049,11 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp) if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); } + + /* SEV requires CPUID[0x8000001F] */ + if (sev_enabled()) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F); + } } /* Set cpuid_*level* based on cpuid_min_*level, if not explicitly set */