From patchwork Thu Feb 15 15:39:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10222107 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 60968602CB for ; Thu, 15 Feb 2018 15:54:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FF3A2943C for ; Thu, 15 Feb 2018 15:54:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 444BC29443; Thu, 15 Feb 2018 15:54:01 +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 A33B22943C for ; Thu, 15 Feb 2018 15:53:59 +0000 (UTC) Received: from localhost ([::1]:60804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emLrB-00021J-Uy for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Feb 2018 10:53:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emLf5-0004zi-TS for qemu-devel@nongnu.org; Thu, 15 Feb 2018 10:41:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emLf0-0003hw-7X for qemu-devel@nongnu.org; Thu, 15 Feb 2018 10:41:27 -0500 Received: from mail-cys01nam02on0064.outbound.protection.outlook.com ([104.47.37.64]:45466 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1emLez-0003hH-W6 for qemu-devel@nongnu.org; Thu, 15 Feb 2018 10:41:22 -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=MSEG7vYOYyg1wqOh5eWOELLSBk4QeYu3ASflFIWtf4E=; b=VnCAgPfb79ZM1vhOUk16dB2QXzd2zvEboCNKQZLOt4BEkIabUJ4EPkpZC3lKQT2Tc3oxC3J9OU0CN7mCQqYQFBgGT2KoJCQbtp5LezkKbBq6vAvBcBQFg+y1NZZpuYfryngL85bh9TfAqb2qQu39NzHe5bUaDgnDYGQFy8SBMdU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Thu, 15 Feb 2018 15:41:17 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 09:39:55 -0600 Message-Id: <20180215153955.3253-30-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180215153955.3253-1-brijesh.singh@amd.com> References: <20180215153955.3253-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR04CA0044.namprd04.prod.outlook.com (10.172.133.30) To SN1PR12MB0157.namprd12.prod.outlook.com (10.162.3.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 832c32bc-c91c-4824-3cf0-08d5748a8e83 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:SN1PR12MB0157; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 3:i4cpJOnfUbYJrDolfJ4iVWQ3XuRBwE/83uoRQ4bhOQBI/kYWVOigbfvMz1dQQrKHH8avkp4+KIWkcb7SBqE7m5z5aENSd461c16iHLEjbmdhRwuqxikzJyFGXRZUE9cbS0VBjObWx7zuWuKpeFk7XcE7TwR4xBidQuSFP4anFWBuZYuSeY7srAauHUybIOYEZfcK249uT9F4JcCPg8T62RESuH4Zaz24yy0WZ/9FH9yzFxSGSZ7nndCa1PruyDcZ; 25:5EaihQOrAY8Z/I9ZDeIGkfCmIDJKjmxEXeHIQYvE+Edl0NRp7178ZHUcRAolzOS+QAHVZUvWZaJj5EfftGSRWb1inUjO9/+a4S8UvKLI12+k+SzBUXHfQm9xRFoGll7sc7XAB/0AnFx/Yr2ziP6yhiaQihjbPKvx85L0w1QdStBfYXGtPEGqgf+ripeDvqPi9xk4fOa58tfpuCCvhbXGn4JmGFi8GdsGA+A3ou1A91aJo1r6b+9XfrIV8KcLllI5+uJ83My2WbvPIXEN62Qm/pbmfGPDYocde+QhwH0Mj/1VLvQZm04YeJ7ObEk0aPa4mPG3SdwosA4hGCxHQvEpFA==; 31:aWJl3WxWUGNz389e1vHGhgdB2EGRsdre6tTY6L5bQBxA79rxTO3RPefV748Oj8jOGMhYrCWYJeSp7mvhphbQqVdBDtt7ucY0SA9Be+9LAKcAZwixsyKDM0fhU+His2Q11zA/I8H9iAXDEC2ALpr5wBBOg84sD3I5fafSjzl+p0r+zovs/2MWoKD6+L6H0DVq/7EWvhUfWK5Gg+VesxdKz418JEuNd0yl1dNXqWFBIl0= X-MS-TrafficTypeDiagnostic: SN1PR12MB0157: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:xc1kTDHspafaI0iOYK6m5AC8VcLLUsqIh++xbJEocQTd/TEpn83Y3gdQWXPWlBt9vuGwhyNDQPbcVuG+HTbHjxtCdoMm83joFz4wAEWKmJp5FbmcTn7HPTXxDi/6ItFKZcHdU2NSazU/PwRJ2mO3GG9YFeK74S0L9X+7zOnEVR1TobzN9hJJpo1sQDrtRkwTIJ/wnm2nPM6O0bmJNgNLTI56ekNxE3a7zSRmEYPPiRx5yOIEsNr6He7R9rVmgROJ0Kjw7kBgDOijAECaFsqB8sECxFmzLmUkBhHWdeHijUuvHeHkm5AqGEdNt5Xw+sT4uEEe4+HO6JBHOTuJCxBX7O3RCARE38dS2jbPFmCYwjBvQ5qDIokTATE3fi6LVIkhJq9ujn1KKrlXRrto+aOqyfxBVYKMBnB5r43LGK6kVjLqdjvexSR+D4WrdaHX7qyMIY94kyG2dj1Dxtc3W5g2Aa/mwyihM7SugX1YVnJoajZoz//PCUJHRsNLDYyoZb/F; 4:obFTl44IYTewhsxWojxbi6Flw2/umhvCzYGfl4Dl6FA7/UeX17xvY82LHcXOQvgjgfFdkBTzjHpkSLm0bCRjq/Eb1/Oq0zTMHgErWB3vPwJXF9RYLJ9qfRtTIqmuYuW0VNUQesxcuqGKBmRqkYAYvN3RKMxZmAePh6b4klewO/cXfPKwmXCmsLHDvxqkdCTWYAhW68YaBfGskfHoQiqeI56/lnDHHH2qLjYE7AJY//qO2DIqXKPDv55TIZK4qjYcPQmcxFNc0rz45L/vOdRkRYBmC2+VsCk/a6zV2CJHJmiD9oOdv/gXUknWFhcCgqAl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231101)(944501161)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:SN1PR12MB0157; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0157; X-Forefront-PRVS: 058441C12A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(376002)(39380400002)(346002)(396003)(39860400002)(366004)(189003)(199004)(26005)(3846002)(386003)(8936002)(5660300001)(186003)(16526019)(316002)(6666003)(6306002)(8666007)(1076002)(54906003)(6116002)(48376002)(50466002)(7416002)(478600001)(59450400001)(8676002)(68736007)(86362001)(16586007)(2906002)(50226002)(39060400002)(2351001)(6916009)(7736002)(106356001)(51416003)(8656006)(52116002)(25786009)(4326008)(97736004)(2950100002)(6486002)(2361001)(36756003)(76176011)(81166006)(53416004)(66066001)(53936002)(81156014)(47776003)(305945005)(105586002)(7696005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0157; 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; SN1PR12MB0157; 23:lIPYDX26EEF4nCWn/ihuM9Bm++g43up+zo9DYLdla?= =?us-ascii?Q?ICbMp9eNELdml44cR0Zb7WZPJNYbH5pfUxxUpf1sQmgnP277eIdYkXI0IIs2?= =?us-ascii?Q?l6JuXfutN6bnkTEjs2xgIrKcmb037vVzsOHfM7ygKJn9T3N+B6qdSGqAyOPI?= =?us-ascii?Q?onJcc6rakahok6wbgADPQ9lH8woK2Q8l8hSsEWOQyyQgEmPZsJQAB1a3I6yP?= =?us-ascii?Q?Ofa4YXiXPl4aZKSPIy81gJBOqGQR8+/r6JmDpVD2jaKj5cI5D+XU11bP45ds?= =?us-ascii?Q?0ezEFp6Y8CUhXgbLRV7hQZ1sg0Tz+1FhCsY0t0BD06aGKudAKlCcF5npgPIS?= =?us-ascii?Q?VUImdSWqKxHYxJeB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A0IEWHMZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0157; 20:f5ATxPzkjgtrBIhhJcRen1NCp4kB+C8GXhxwepLKKDMQzzG//IsZu1bxfLDCDHc+HtP68h/SH+So9AuMshB10JoZLNS1XquwpJQP0n28iylKwJ/G9NfEso3TFkMWpxmgirwDbaTQLkOYJRPbqwmgz81cGjEiJyFXrGA+sHDRIEMGiDp8FCupCBoUaqvbDDwFnm2IjTOaQTDhiUpptKDwGfxOJ15n5JoR8+qGWea2cD3ob8hccrWZhkWklaUGOl10 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2018 15:41:17.1504 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 832c32bc-c91c-4824-3cf0-08d5748a8e83 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0157 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.64 Subject: [Qemu-devel] [PATCH v9 29/29] 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 --- target/i386/cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b5e431e769da..6b8284ef9d7c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -25,6 +25,7 @@ #include "sysemu/kvm.h" #include "sysemu/hvf.h" #include "sysemu/cpus.h" +#include "sysemu/sev.h" #include "kvm_i386.h" #include "qemu/error-report.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 */