From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632833943849858.6607003231203; Tue, 28 Sep 2021 05:59:03 -0700 (PDT) Received: from localhost ([::1]:45372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVChK-0005kN-S3 for importer@patchew.org; Tue, 28 Sep 2021 08:59:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa1-0006N8-Gm for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:29 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:33758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCZt-0001J3-Qt for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:25 -0400 Received: by mail-ed1-x52d.google.com with SMTP id b26so34523127edt.0 for ; Tue, 28 Sep 2021 05:51:20 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HTQc9AFcRDhvJrgR1HuvP2H0f8isuj93MihqGubbVPI=; b=c9fQsSsxKIrcxRSarTZb/QlBGYAyDrEkIZGppyFYPZPm+L0Do5egKy9xI1+QeueQRm Sy2cVYO/rQGZZ9za5J3N7MsRo+UAekg7E0cuLn0TBqrZbKZOxptN+bdOVPBaXEiQp88x ehdLWm2pMyUda+Jtk/h+LV8v5ZGaFFEAHzyCALlz7O8Fybi1Cld0L3SpLmvQE6qI1Wse fLe2fvvKOc+j1AYMp/TBRkftUgJYC3pjWum+4aTEFRRjxj4tcgNLKf6kruxh7qEyEn/Z jhWK1Nki7NyBBXSaa0jpdRBP65UApnoRKz11FX7HjXJ9t26iSQ7PmUfRoPNhBmRzuSXe wi1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HTQc9AFcRDhvJrgR1HuvP2H0f8isuj93MihqGubbVPI=; b=ox82nbEdiIVXYJUopERFXd2gp21Bo9IRsuqSwy440xNNFKnewt4KwpNg5GrkugJxXE XmFEwpUyLLzdA0bH3YX9xx3Hvm6REF4TzzB6TQ7H+QqSupL/Z0jDQNh0DiXG1lcdbN9b kLXmgnwBK8+oJpV0L/X41DoVlbdoDP0c0xgoUVLdnhjatkG+SQLQ4DNLLBYSvohgMk6+ JszV7zXfOkxj8/14jLQu/rRQWFlxtw2WTV3n3ZhJfw9cyZXoG9fXRT0HizIr3dRqa3sw BNr7uAgGHr/atYTNdnX7UyOOCkDJXBF9l/CAd7WEY14daOlPdVV7B/k1xZ+unF2//y6+ bslg== X-Gm-Message-State: AOAM532007qRSHKmfeTb6Yz3qwqbm631C0pAc0TGPPSICM9t/kit4tfL 6qaSGFqWjs5OzaRue23jDN1XozdRvx8= X-Google-Smtp-Source: ABdhPJwg0Lp7rekQqCUrHG4z/k6fXxaVMtDDnmrnKPNuAScn9wlJeDE98DOXW3Il6cWjCdrqLDpvaw== X-Received: by 2002:a50:be87:: with SMTP id b7mr7602776edk.382.1632833479661; Tue, 28 Sep 2021 05:51:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/33] memory: Add RAM_PROTECTED flag to skip IOMMU mappings Date: Tue, 28 Sep 2021 14:50:44 +0200 Message-Id: <20210928125116.183620-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632833944826100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Add a new RAMBlock flag to denote "protected" memory, i.e. memory that looks and acts like RAM but is inaccessible via normal mechanisms, including DMA. Use the flag to skip protected memory regions when mapping RAM for DMA in VFIO. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Signed-off-by: Paolo Bonzini --- hw/vfio/common.c | 1 + include/exec/memory.h | 15 ++++++++++++++- softmmu/memory.c | 5 +++++ softmmu/physmem.c | 3 ++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 8728d4d5c2..1289cfa8be 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -562,6 +562,7 @@ static bool vfio_listener_skipped_section(MemoryRegionS= ection *section) { return (!memory_region_is_ram(section->mr) && !memory_region_is_iommu(section->mr)) || + memory_region_is_protected(section->mr) || /* * Sizing an enabled 64-bit BAR can cause spurious mappings to * addresses in the upper part of the 64-bit address space. Th= ese diff --git a/include/exec/memory.h b/include/exec/memory.h index c3d417d317..9446874d21 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -190,6 +190,9 @@ typedef struct IOMMUTLBEvent { */ #define RAM_NORESERVE (1 << 7) =20 +/* RAM that isn't accessible through normal means. */ +#define RAM_PROTECTED (1 << 8) + static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, IOMMUNotifierFlag flags, hwaddr start, hwaddr end, @@ -1267,7 +1270,7 @@ void memory_region_init_ram_from_file(MemoryRegion *m= r, * @name: the name of the region. * @size: size of the region. * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM, - * RAM_NORESERVE. + * RAM_NORESERVE, RAM_PROTECTED. * @fd: the fd to mmap. * @offset: offset within the file referenced by fd * @errp: pointer to Error*, to store an error if it happens. @@ -1568,6 +1571,16 @@ static inline bool memory_region_is_romd(MemoryRegio= n *mr) return mr->rom_device && mr->romd_mode; } =20 +/** + * memory_region_is_protected: check whether a memory region is protected + * + * Returns %true if a memory region is protected RAM and cannot be accessed + * via standard mechanisms, e.g. DMA. + * + * @mr: the memory region being queried + */ +bool memory_region_is_protected(MemoryRegion *mr); + /** * memory_region_get_iommu: check whether a memory region is an iommu * diff --git a/softmmu/memory.c b/softmmu/memory.c index bfedaf9c4d..54cd0e9824 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1811,6 +1811,11 @@ bool memory_region_is_ram_device(MemoryRegion *mr) return mr->ram_device; } =20 +bool memory_region_is_protected(MemoryRegion *mr) +{ + return mr->ram && (mr->ram_block->flags & RAM_PROTECTED); +} + uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) { uint8_t mask =3D mr->dirty_log_mask; diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 23e77cb771..088660d973 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2055,7 +2055,8 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, int64_t file_size, file_align; =20 /* Just support these ram flags by now. */ - assert((ram_flags & ~(RAM_SHARED | RAM_PMEM | RAM_NORESERVE)) =3D=3D 0= ); + assert((ram_flags & ~(RAM_SHARED | RAM_PMEM | RAM_NORESERVE | + RAM_PROTECTED)) =3D=3D 0); =20 if (xen_enabled()) { error_setg(errp, "-mem-path not supported with Xen"); --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163283378913611.421155371768691; Tue, 28 Sep 2021 05:56:29 -0700 (PDT) Received: from localhost ([::1]:39364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCen-0001f5-3w for importer@patchew.org; Tue, 28 Sep 2021 08:56:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa2-0006OV-Qk for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:33 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:39690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCZw-0001Kd-Qg for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:29 -0400 Received: by mail-ed1-x536.google.com with SMTP id x7so68154507edd.6 for ; Tue, 28 Sep 2021 05:51:24 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=36xUxYH1Afi8N5W5cIUwxmt2NMki93xyDotZiunEpyA=; b=esFs6DiYn/Jn0kSuFabKp2Yor2e1gaNf9HUl4vlcc3+zndN0I4m7pjegLtxzkmKIwz X/PUtyVuvS6xCGD1Hs9EOC5nXq4vdX0vID3PC+igD4BQPXUie3pMKEss2iJ2Wydm8/eM FRwniKQoy+y8GAenUmvI3fpRsF7ZjB1F9VQPnJC/1QRJxPSPW6GQt8CBph1QYiLqjFew iU9FArRfXZP+6wxZHoPZ6sw9ACdQHfXd/Nr/ro0rrMRgGMLCSHLaia8vAZyvQz+1gyDV JEeCgqANk0LIRLPPdWoXkX0cg+0j/tNtj2rR/mLG78e9IpfJLbBBhohSIw6YGesvCoZX xHbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=36xUxYH1Afi8N5W5cIUwxmt2NMki93xyDotZiunEpyA=; b=D/40tE6zFdymkGCZvk1HylYmF+Gbec4uytMsxe8ha4Js+vbI204Mqd/NFFMw+ioL4I GX6MHHUZfcSoTju2Gy/K/TvaT6nuK2443jwlPzv72qv10G4cEo6fXsEWHfmiQkHS0Bi1 MgReKq7AYHttdqUS2Ir+gpBky+G2PMlOsfwiFC6oGRG5GAH66XT6kFoC7GboHbdVo70s pR8h5CRRe6ClF4/arBAq2hGtEvAytAkfKpUQWlMZ+7LR7OAutDivKA3+zWX4g75aDErF dtD5ABomBODRPQJ6VeK1K76DMZ3xFPS0EksBS4r/cdd2s6R0TA1efm1Jo0/H0mrql47v FvCw== X-Gm-Message-State: AOAM533NUcRIMRF5KhJIXxZTUa9rUpnaW7M6YQgVswu/cXsFz2rf/GGR 6+9S2TYOCerhVUFvO6mvjpfHpWBgIPE= X-Google-Smtp-Source: ABdhPJyleaWHD5g9BnnhQOVL2SpryqKYaVMsG4KZYvb5Y/c8QcEWt+rFAD77gAUzAC3quziKDiyf1A== X-Received: by 2002:a50:e0c8:: with SMTP id j8mr7243608edl.283.1632833480453; Tue, 28 Sep 2021 05:51:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/33] Kconfig: Add CONFIG_SGX support Date: Tue, 28 Sep 2021 14:50:45 +0200 Message-Id: <20210928125116.183620-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632833789757100001 Content-Type: text/plain; charset="utf-8" From: Yang Zhong Add new CONFIG_SGX for sgx support in the Qemu, and the Kconfig default enable sgx in the i386 platform. Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-32-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- configs/devices/i386-softmmu/default.mak | 1 + hw/i386/Kconfig | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/configs/devices/i386-softmmu/default.mak b/configs/devices/i38= 6-softmmu/default.mak index 84d1a2487c..598c6646df 100644 --- a/configs/devices/i386-softmmu/default.mak +++ b/configs/devices/i386-softmmu/default.mak @@ -22,6 +22,7 @@ #CONFIG_TPM_CRB=3Dn #CONFIG_TPM_TIS_ISA=3Dn #CONFIG_VTD=3Dn +#CONFIG_SGX=3Dn =20 # Boards: # diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index ddedcef0b2..962d2c981b 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -6,6 +6,10 @@ config SEV select X86_FW_OVMF depends on KVM =20 +config SGX + bool + depends on KVM + config PC bool imply APPLESMC @@ -21,6 +25,7 @@ config PC imply PVPANIC_ISA imply QXL imply SEV + imply SGX imply SGA imply TEST_DEVICES imply TPM_CRB --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632833954079823.8382646757508; Tue, 28 Sep 2021 05:59:14 -0700 (PDT) Received: from localhost ([::1]:46322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVChV-0006Or-40 for importer@patchew.org; Tue, 28 Sep 2021 08:59:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa3-0006OZ-JN for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:34 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:47096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa1-0001M8-Bj for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:31 -0400 Received: by mail-ed1-x52f.google.com with SMTP id dn26so5832713edb.13 for ; Tue, 28 Sep 2021 05:51:26 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T6Lr8ErbwMyyYfXEZLpi47v8UMegyeRPBkfE+yqfiHU=; b=LHAedOQGHuQj2um+8zFKwYCn93thhGbF9UmVN9ZriML0pAz4ezxq0JuokiVTljFkrn 1N34wrXtFHcznF2TM7xwec539wIL3ToukIdZXwk65SYnZlG5GPCfdWDlmtA74XRaG5Jd IuQArWqq2s33pl+uQuNkYsz5m+0X6bK80s2WSuvb5VzRklEaFZt/8ucbcok9ZgTRIyA4 kwMkc1BMwg9fOiK2n9+M7ifoJheYnXlEiOs8jLjLGl4mMKCnI5MQaHqWsyznzSAvKMD8 6ZTem1XCwRIQx+TgcCauy0iAoWejD5PN82AQW61SPmHZ3ScdGoPvw9Vxp/mdVxsaVbaz ysFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=T6Lr8ErbwMyyYfXEZLpi47v8UMegyeRPBkfE+yqfiHU=; b=gi2HDLqI8qxFyEm9HLab0C2FKbBLrLbDmEOB0EkcabzLTxvun18LGIDQUEahmThbvW 4+hxzCIbOZo78tYArIeYmMnPDNrmLJGacC8nSA4gFb8/VWqDLIWuhT848dU3+bZEJarc vFgzcbovsRkNPck3wW4g4tXoGCaaBes9DDehsO1D/Ei4uFlZLGdnT35jtC/+Ptlqe84A aDppQK832UumgvNJ7a445CvW5xB+yANnk5TWpqBPlTK4FTOt6usdDxUUm7cXoAtJfqJk X8KUYdt+kWoTA0zZYRxFNgVtWEH7pFMHy1o+1MWQK29JCouZMuEkR5+rf4J0mL8O2S1E oQeA== X-Gm-Message-State: AOAM533aoBeHCoMkfxipC+nBQFFpq2xM36gx5mqNwYk4ZiYh6s6BSd48 6y5aZWzyXiAGKJCs4lJUAvJ9EhCv7SY= X-Google-Smtp-Source: ABdhPJyUOx0QpKktPaQaRi7uS+3dZkp+ADtM853RaFSztuT97ia0hulKf/tQLGt+RTtqvNYq5vgNPw== X-Received: by 2002:a17:906:12d4:: with SMTP id l20mr6063378ejb.43.1632833481224; Tue, 28 Sep 2021 05:51:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/33] hostmem: Add hostmem-epc as a backend for SGX EPC Date: Tue, 28 Sep 2021 14:50:46 +0200 Message-Id: <20210928125116.183620-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632833956186100003 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson EPC (Enclave Page Cahe) is a specialized type of memory used by Intel SGX (Software Guard Extensions). The SDM desribes EPC as: The Enclave Page Cache (EPC) is the secure storage used to store enclave pages when they are a part of an executing enclave. For an EPC page, hardware performs additional access control checks to restrict access to the page. After the current page access checks and translations are performed, the hardware checks that the EPC page is accessible to the program currently executing. Generally an EPC page is only accessed by the owner of the executing enclave or an instruction which is setting up an EPC page. Because of its unique requirements, Linux manages EPC separately from normal memory. Similar to memfd, the device /dev/sgx_vepc can be opened to obtain a file descriptor which can in turn be used to mmap() EPC memory. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-3-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- backends/hostmem-epc.c | 82 +++++++++++++++++++++++++++++++++++ backends/meson.build | 1 + include/hw/i386/hostmem-epc.h | 28 ++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 backends/hostmem-epc.c create mode 100644 include/hw/i386/hostmem-epc.h diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c new file mode 100644 index 0000000000..b47f98b6a3 --- /dev/null +++ b/backends/hostmem-epc.c @@ -0,0 +1,82 @@ +/* + * QEMU host SGX EPC memory backend + * + * Copyright (C) 2019 Intel Corporation + * + * Authors: + * Sean Christopherson + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qom/object_interfaces.h" +#include "qapi/error.h" +#include "sysemu/hostmem.h" +#include "hw/i386/hostmem-epc.h" + +static void +sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) +{ + uint32_t ram_flags; + char *name; + int fd; + + if (!backend->size) { + error_setg(errp, "can't create backend with size 0"); + return; + } + + fd =3D qemu_open_old("/dev/sgx_vepc", O_RDWR); + if (fd < 0) { + error_setg_errno(errp, errno, + "failed to open /dev/sgx_vepc to alloc SGX EPC"); + return; + } + + name =3D object_get_canonical_path(OBJECT(backend)); + ram_flags =3D (backend->share ? RAM_SHARED : 0) | RAM_PROTECTED; + memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), + name, backend->size, ram_flags, + fd, 0, errp); + g_free(name); +} + +static void sgx_epc_backend_instance_init(Object *obj) +{ + HostMemoryBackend *m =3D MEMORY_BACKEND(obj); + + m->share =3D true; + m->merge =3D false; + m->dump =3D false; +} + +static void sgx_epc_backend_class_init(ObjectClass *oc, void *data) +{ + HostMemoryBackendClass *bc =3D MEMORY_BACKEND_CLASS(oc); + + bc->alloc =3D sgx_epc_backend_memory_alloc; +} + +static const TypeInfo sgx_epc_backed_info =3D { + .name =3D TYPE_MEMORY_BACKEND_EPC, + .parent =3D TYPE_MEMORY_BACKEND, + .instance_init =3D sgx_epc_backend_instance_init, + .class_init =3D sgx_epc_backend_class_init, + .instance_size =3D sizeof(HostMemoryBackendEpc), +}; + +static void register_types(void) +{ + int fd =3D qemu_open_old("/dev/sgx_vepc", O_RDWR); + if (fd >=3D 0) { + close(fd); + + type_register_static(&sgx_epc_backed_info); + } +} + +type_init(register_types); diff --git a/backends/meson.build b/backends/meson.build index d4221831fc..6e68945528 100644 --- a/backends/meson.build +++ b/backends/meson.build @@ -16,5 +16,6 @@ softmmu_ss.add(when: ['CONFIG_VHOST_USER', 'CONFIG_VIRTIO= '], if_true: files('vho softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vho= st.c')) softmmu_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VHOST_CRYPTO'], if_t= rue: files('cryptodev-vhost-user.c')) softmmu_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus-vmstate.c'), gio]) +softmmu_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c')) =20 subdir('tpm') diff --git a/include/hw/i386/hostmem-epc.h b/include/hw/i386/hostmem-epc.h new file mode 100644 index 0000000000..846c726085 --- /dev/null +++ b/include/hw/i386/hostmem-epc.h @@ -0,0 +1,28 @@ +/* + * SGX EPC backend + * + * Copyright (C) 2019 Intel Corporation + * + * Authors: + * Sean Christopherson + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_HOSTMEM_EPC_H +#define QEMU_HOSTMEM_EPC_H + +#include "sysemu/hostmem.h" + +#define TYPE_MEMORY_BACKEND_EPC "memory-backend-epc" + +#define MEMORY_BACKEND_EPC(obj) \ + OBJECT_CHECK(HostMemoryBackendEpc, (obj), TYPE_MEMORY_BACKEND_EPC) + +typedef struct HostMemoryBackendEpc HostMemoryBackendEpc; + +struct HostMemoryBackendEpc { + HostMemoryBackend parent_obj; +}; + +#endif --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834436333551.4872406747385; Tue, 28 Sep 2021 06:07:16 -0700 (PDT) Received: from localhost ([::1]:34140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCpH-0000VZ-By for importer@patchew.org; Tue, 28 Sep 2021 09:07:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa3-0006OX-52 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:33 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:43566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa0-0001Kt-FX for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:30 -0400 Received: by mail-ed1-x532.google.com with SMTP id v10so78449250edj.10 for ; Tue, 28 Sep 2021 05:51:25 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gW5+cqtFW8998bP2+Q+N3gwvZIfrKBuSNRSwxC4KxeU=; b=b1LL6PkSZHHjD9NQOLGJ7L1MiBY+qoqnjC7jRgNvzrTUm3Ig3acWUUc+4eI+OasDKb pb2hGjyjjolErCicx2CJ5cV0XnJmSUrikteDTDjoC8+yR3xlRWvnhTnJ8eoOARuoHQiH lRXOu7GvyxQBEgFVW9aLNg00xm3lufyU0UeqYD8QndpzjZN+QtCoWvRHp6N9zo4iasxM keg6kv5bFOALNU48ckeWJmFy7ogiqrSAGbJrnDGo6b6j3CRgt8Co788frZ0d1bqQH/Cq VdbcxemC/nVrabZemSrZJ5VahTmUPERiBb+ObwfGGUNqAIMdOblQDJGicCk44VwvN0hG X1qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=gW5+cqtFW8998bP2+Q+N3gwvZIfrKBuSNRSwxC4KxeU=; b=f3dIFwoBBkniQz6P9So2sP11I5S2juRZAQeLmp/P7GaNEagVL4ft1rz07RWF/4VCf5 M1aQTs/+Z8gC6ioi7Kp1NodHfPMuGGFQg6OxMTP0TODUxSFNIWbch0tzBKG/P5YeAt9H 8OivsQ/+aJsBm5GUVUgVvqTg7/Fp/nKfJ5r8SMvdO7nrgW3i5+9B1pI9oGKAqjJd96Ka 2nuYOI+r3GtrQfVEL0WP3R7pKjwqm1YxdaCzsIcCe19v5LspmO4a9Uk3I3vp0kgrVPMB jbNcgapyfmw29XM7fFU4MXq3P+fSH3BYHJFME5rnKQ8gbUHqD6ZMbRpO/wp3nFpOqjtl Q3Fw== X-Gm-Message-State: AOAM532LTu6ZPi8Er4hCHU9me/Y7uP6M5OqqDT+vD5XnuOzrcp8BMg3E KHX2cBGCp3mnAoBFizjTeyBfuL2nI1Q= X-Google-Smtp-Source: ABdhPJzS7zvAWrmWksbj56VCmkQIm0w7y3SPAiVDDuV+0eC6BqaQLyHI5epg3pGPdxHj11YQaijNlA== X-Received: by 2002:a17:906:d9ca:: with SMTP id qk10mr354545ejb.220.1632833482038; Tue, 28 Sep 2021 05:51:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/33] qom: Add memory-backend-epc ObjectOptions support Date: Tue, 28 Sep 2021 14:50:47 +0200 Message-Id: <20210928125116.183620-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834437707100001 Content-Type: text/plain; charset="utf-8" From: Yang Zhong Add the new 'memory-backend-epc' user creatable QOM object in the ObjectOptions to support SGX since v6.1, or the sgx backend object cannot bootup. Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-4-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- qapi/qom.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qapi/qom.json b/qapi/qom.json index a25616bc7a..0222bb4506 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -647,6 +647,23 @@ '*hugetlbsize': 'size', '*seal': 'bool' } } =20 +## +# @MemoryBackendEpcProperties: +# +# Properties for memory-backend-epc objects. +# +# The @share boolean option is true by default with epc +# +# The @merge boolean option is false by default with epc +# +# The @dump boolean option is false by default with epc +# +# Since: 6.2 +## +{ 'struct': 'MemoryBackendEpcProperties', + 'base': 'MemoryBackendProperties', + 'data': {} } + ## # @PrManagerHelperProperties: # @@ -797,6 +814,7 @@ { 'name': 'memory-backend-memfd', 'if': 'CONFIG_LINUX' }, 'memory-backend-ram', + 'memory-backend-epc', 'pef-guest', 'pr-manager-helper', 'qtest', @@ -855,6 +873,7 @@ 'memory-backend-memfd': { 'type': 'MemoryBackendMemfdPropertie= s', 'if': 'CONFIG_LINUX' }, 'memory-backend-ram': 'MemoryBackendProperties', + 'memory-backend-epc': 'MemoryBackendEpcProperties', 'pr-manager-helper': 'PrManagerHelperProperties', 'qtest': 'QtestProperties', 'rng-builtin': 'RngProperties', --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632833955132294.342296424153; Tue, 28 Sep 2021 05:59:15 -0700 (PDT) Received: from localhost ([::1]:46352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVChW-0006Q5-2O for importer@patchew.org; Tue, 28 Sep 2021 08:59:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa3-0006Oa-LL for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:34 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:39682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa1-0001MB-5q for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:31 -0400 Received: by mail-ed1-x52c.google.com with SMTP id x7so68154958edd.6 for ; Tue, 28 Sep 2021 05:51:26 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EKKzobHFyXxpWUiNzYO7LLzXVu+MAqFExSkV+Wsg/vk=; b=V7lqK8EBRrTvy5YkzSnvvIsLZeilkKbsHCm18/Jst/WsZuQdyNove4G9UCksYWq8RN WD2t8UuA/gFc9OYUUe4m7ovOg/cSk5VNXWWFW+sbisiqsa9sP4ve9F7Z3iVbUEphywmp 5X4ymNGCkxR3WEF3Qmfc6VZcQdCANYXpBvEiC8+6BLGIOPlJ0eF57tJ8kx3Ed/+9dn3e Oto+Uslz4EWuOC7giaByRimI2hcmCjN+ag3IF408cRw+HDVvBCXwDzeHPYmt4n3cObwI skMHXn+/qnFY8pXMlnSgBZxn585X4Lik2zSU47J6vF9zBe9kXLCCj6XUwrPmTZGEsJcF wa5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=EKKzobHFyXxpWUiNzYO7LLzXVu+MAqFExSkV+Wsg/vk=; b=EPbtQiyKQQqkCgZdD8lttgyHfH1KVyMKgh/5hEbd+E4eQWqOFEBuD1/isAVJakxTw3 Spit+1wTmPaTxiJn63JGu1cGxXb2Jj3s+MhviMKF6qc+9NDWtxhlwsF83pDHNb+JUQX5 f4xzSueIL+ci2begkYcPJvZFetIdayj+gHbwg5QklinGtKLZOsu0kmcaH2OFyBGegBYr 3BRIALX8PbBid2dTkT8yTR8BIBFHPZGKcm9AoZXhYXKQFoHJ1tSb93IyPkr9uHLD0xd6 5+15lMAIZlgH0VnoQ+ChXRyQykMw+BenS6S//vGAeZE84Em+tk6AS7W5CfnBlA2dUkZA imkg== X-Gm-Message-State: AOAM531yPNGbD5vnFGoCJhj2cl4CXJ9rUb8K6JB9S3R50cWJomUQ8JCZ o37hadJ4UytPWUm3Gk16HGss8vvhObk= X-Google-Smtp-Source: ABdhPJxNNAizh10hTkKAKu0mAe4jETkHwyKcGzeuXZ1kM+Kc5uunpW34vbAMmqRJ507N53Eliye6jw== X-Received: by 2002:a17:906:2c46:: with SMTP id f6mr6347641ejh.542.1632833482783; Tue, 28 Sep 2021 05:51:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/33] i386: Add 'sgx-epc' device to expose EPC sections to guest Date: Tue, 28 Sep 2021 14:50:48 +0200 Message-Id: <20210928125116.183620-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632833956344100005 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson SGX EPC is enumerated through CPUID, i.e. EPC "devices" need to be realized prior to realizing the vCPUs themselves, which occurs long before generic devices are parsed and realized. Because of this, do not allow 'sgx-epc' devices to be instantiated after vCPUS have been created. The 'sgx-epc' device is essentially a placholder at this time, it will be fully implemented in a future patch along with a dedicated command to create 'sgx-epc' devices. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-5-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/meson.build | 1 + hw/i386/sgx-epc.c | 167 ++++++++++++++++++++++++++++++++++++++ include/hw/i386/sgx-epc.h | 44 ++++++++++ 3 files changed, 212 insertions(+) create mode 100644 hw/i386/sgx-epc.c create mode 100644 include/hw/i386/sgx-epc.h diff --git a/hw/i386/meson.build b/hw/i386/meson.build index 80dad29f2b..b1862c83d4 100644 --- a/hw/i386/meson.build +++ b/hw/i386/meson.build @@ -16,6 +16,7 @@ i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c'= )) i386_ss.add(when: 'CONFIG_VMMOUSE', if_true: files('vmmouse.c')) i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport.c')) i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c')) +i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c')) =20 i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c')) i386_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_= device_x86.c')) diff --git a/hw/i386/sgx-epc.c b/hw/i386/sgx-epc.c new file mode 100644 index 0000000000..c584acc17b --- /dev/null +++ b/hw/i386/sgx-epc.c @@ -0,0 +1,167 @@ +/* + * SGX EPC device + * + * Copyright (C) 2019 Intel Corporation + * + * Authors: + * Sean Christopherson + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "hw/i386/pc.h" +#include "hw/i386/sgx-epc.h" +#include "hw/mem/memory-device.h" +#include "hw/qdev-properties.h" +#include "monitor/qdev.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/units.h" +#include "target/i386/cpu.h" +#include "exec/address-spaces.h" + +static Property sgx_epc_properties[] =3D { + DEFINE_PROP_UINT64(SGX_EPC_ADDR_PROP, SGXEPCDevice, addr, 0), + DEFINE_PROP_LINK(SGX_EPC_MEMDEV_PROP, SGXEPCDevice, hostmem, + TYPE_MEMORY_BACKEND_EPC, HostMemoryBackendEpc *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void sgx_epc_get_size(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Error *local_err =3D NULL; + uint64_t value; + + value =3D memory_device_get_region_size(MEMORY_DEVICE(obj), &local_err= ); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + visit_type_uint64(v, name, &value, errp); +} + +static void sgx_epc_init(Object *obj) +{ + object_property_add(obj, SGX_EPC_SIZE_PROP, "uint64", sgx_epc_get_size, + NULL, NULL, NULL); +} + +static void sgx_epc_realize(DeviceState *dev, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); + X86MachineState *x86ms =3D X86_MACHINE(pcms); + SGXEPCDevice *epc =3D SGX_EPC(dev); + HostMemoryBackend *hostmem; + const char *path; + + if (x86ms->boot_cpus !=3D 0) { + error_setg(errp, "'" TYPE_SGX_EPC "' can't be created after vCPUs," + "e.g. via -device"); + return; + } + + if (!epc->hostmem) { + error_setg(errp, "'" SGX_EPC_MEMDEV_PROP "' property is not set"); + return; + } + hostmem =3D MEMORY_BACKEND(epc->hostmem); + if (host_memory_backend_is_mapped(hostmem)) { + path =3D object_get_canonical_path_component(OBJECT(hostmem)); + error_setg(errp, "can't use already busy memdev: %s", path); + return; + } + + error_setg(errp, "'" TYPE_SGX_EPC "' not supported"); +} + +static void sgx_epc_unrealize(DeviceState *dev) +{ + SGXEPCDevice *epc =3D SGX_EPC(dev); + HostMemoryBackend *hostmem =3D MEMORY_BACKEND(epc->hostmem); + + host_memory_backend_set_mapped(hostmem, false); +} + +static uint64_t sgx_epc_md_get_addr(const MemoryDeviceState *md) +{ + const SGXEPCDevice *epc =3D SGX_EPC(md); + + return epc->addr; +} + +static void sgx_epc_md_set_addr(MemoryDeviceState *md, uint64_t addr, + Error **errp) +{ + object_property_set_uint(OBJECT(md), SGX_EPC_ADDR_PROP, addr, errp); +} + +static uint64_t sgx_epc_md_get_plugged_size(const MemoryDeviceState *md, + Error **errp) +{ + return 0; +} + +static MemoryRegion *sgx_epc_md_get_memory_region(MemoryDeviceState *md, + Error **errp) +{ + SGXEPCDevice *epc =3D SGX_EPC(md); + HostMemoryBackend *hostmem; + + if (!epc->hostmem) { + error_setg(errp, "'" SGX_EPC_MEMDEV_PROP "' property must be set"); + return NULL; + } + + hostmem =3D MEMORY_BACKEND(epc->hostmem); + return host_memory_backend_get_memory(hostmem); +} + +static void sgx_epc_md_fill_device_info(const MemoryDeviceState *md, + MemoryDeviceInfo *info) +{ + /* TODO */ +} + +static void sgx_epc_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + MemoryDeviceClass *mdc =3D MEMORY_DEVICE_CLASS(oc); + + dc->hotpluggable =3D false; + dc->realize =3D sgx_epc_realize; + dc->unrealize =3D sgx_epc_unrealize; + dc->desc =3D "SGX EPC section"; + device_class_set_props(dc, sgx_epc_properties); + + mdc->get_addr =3D sgx_epc_md_get_addr; + mdc->set_addr =3D sgx_epc_md_set_addr; + mdc->get_plugged_size =3D sgx_epc_md_get_plugged_size; + mdc->get_memory_region =3D sgx_epc_md_get_memory_region; + mdc->fill_device_info =3D sgx_epc_md_fill_device_info; +} + +static TypeInfo sgx_epc_info =3D { + .name =3D TYPE_SGX_EPC, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(SGXEPCDevice), + .instance_init =3D sgx_epc_init, + .class_init =3D sgx_epc_class_init, + .class_size =3D sizeof(DeviceClass), + .interfaces =3D (InterfaceInfo[]) { + { TYPE_MEMORY_DEVICE }, + { } + }, +}; + +static void sgx_epc_register_types(void) +{ + type_register_static(&sgx_epc_info); +} + +type_init(sgx_epc_register_types) diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h new file mode 100644 index 0000000000..cf3ed5c0cd --- /dev/null +++ b/include/hw/i386/sgx-epc.h @@ -0,0 +1,44 @@ +/* + * SGX EPC device + * + * Copyright (C) 2019 Intel Corporation + * + * Authors: + * Sean Christopherson + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_SGX_EPC_H +#define QEMU_SGX_EPC_H + +#include "hw/i386/hostmem-epc.h" + +#define TYPE_SGX_EPC "sgx-epc" +#define SGX_EPC(obj) \ + OBJECT_CHECK(SGXEPCDevice, (obj), TYPE_SGX_EPC) +#define SGX_EPC_CLASS(oc) \ + OBJECT_CLASS_CHECK(SGXEPCDeviceClass, (oc), TYPE_SGX_EPC) +#define SGX_EPC_GET_CLASS(obj) \ + OBJECT_GET_CLASS(SGXEPCDeviceClass, (obj), TYPE_SGX_EPC) + +#define SGX_EPC_ADDR_PROP "addr" +#define SGX_EPC_SIZE_PROP "size" +#define SGX_EPC_MEMDEV_PROP "memdev" + +/** + * SGXEPCDevice: + * @addr: starting guest physical address, where @SGXEPCDevice is mapped. + * Default value: 0, means that address is auto-allocated. + * @hostmem: host memory backend providing memory for @SGXEPCDevice + */ +typedef struct SGXEPCDevice { + /* private */ + DeviceState parent_obj; + + /* public */ + uint64_t addr; + HostMemoryBackendEpc *hostmem; +} SGXEPCDevice; + +#endif --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632833971705381.2520961201757; Tue, 28 Sep 2021 05:59:31 -0700 (PDT) Received: from localhost ([::1]:47968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVChm-0007W7-GT for importer@patchew.org; Tue, 28 Sep 2021 08:59:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa3-0006OY-8K for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:33 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:41955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa1-0001La-1J for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:30 -0400 Received: by mail-ed1-x530.google.com with SMTP id s17so64107110edd.8 for ; Tue, 28 Sep 2021 05:51:26 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4mT6xXkpc8blw20HU3aytQAk+55YTpi/iG5uUvlQ984=; b=U8fCiNfK0h8vVypCQlVbdOuMOYtafsuaLH+G6t9L1ve5eeoVJUvy3E/5QrYeQjObNa c5JL+pfpn/dHDewH0O/RKsGrvWf/Sccliud7+UTMMTYVsU/rSMmdh+tqAt/SvGKb6ldg dTgkRacNfQS79Duhok40WiVvfJ3+Zc9iCRQBdcSAhDmTFXmMT74lPhbO35/o2XGovGnt g7sckgzb88i2ZdHmrDNHGh9QdUBuEwRrmB8fxG2YINnc2ACyDdlckCqZj5/A6st1txGh R2uPEzrjTCfUqyQL7DMnl+b1IwtHDr1D1gUcoShvSPoLmVyu54C9311EAy5VmZJeCDh6 wMVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4mT6xXkpc8blw20HU3aytQAk+55YTpi/iG5uUvlQ984=; b=Q9wtyOdCGq+2yfQdxFnR6JxURT7NS+MwHY5Vptxzy+eP3FRUCUMG4gLtlMd2Rs19h0 BO/cpc5SxU/0VM1ln+ULXhOShZ4dhZ2u5SnSicpKZCHCSbxKclyZ9qgo21FnhD0OaxR5 tVLCMpcbyF3ixr9rbvMUKKm3Owl7UJoPBXIMNOsKvP/fks8qDkEz3HFVXA35lgsWTjp6 4IjLsAcYWxDJybbwOuZdmItulkOgMz2OsHrgdgWCX2KNWEmR+RWjEpGDctLLoximHTM3 BJkcWsnq0g6rWZCo8dSNlIfsW4BTV+Vp4u5J79mVc7acvpVszG0ExbtFT+MPiG/T7ZRz 6P6Q== X-Gm-Message-State: AOAM531TKpfAVGkaxuCMMj62uuYvyiXyeSFK4zIsk8GNOOfDu1AEMeLx hNyv5L65NXuPw+Ue94ErGbVRbkUDqj4= X-Google-Smtp-Source: ABdhPJxPMLnK73Kj0wmL0xGEyQd3Gw++fAuFpGWRV0ZK9dv2es8qyuaS6l/fuTY61hOdNdLmWBea+g== X-Received: by 2002:a17:906:7d83:: with SMTP id v3mr6677412ejo.216.1632833483583; Tue, 28 Sep 2021 05:51:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 06/33] vl: Add sgx compound properties to expose SGX EPC sections to guest Date: Tue, 28 Sep 2021 14:50:49 +0200 Message-Id: <20210928125116.183620-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632833973698100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Because SGX EPC is enumerated through CPUID, EPC "devices" need to be realized prior to realizing the vCPUs themselves, i.e. long before generic devices are parsed and realized. From a virtualization perspective, the CPUID aspect also means that EPC sections cannot be hotplugged without paravirtualizing the guest kernel (hardware does not support hotplugging as EPC sections must be locked down during pre-boot to provide EPC's security properties). So even though EPC sections could be realized through the generic -devices command, they need to be created much earlier for them to actually be usable by the guest. Place all EPC sections in a contiguous block, somewhat arbitrarily starting after RAM above 4g. Ensuring EPC is in a contiguous region simplifies calculations, e.g. device memory base, PCI hole, etc..., allows dynamic calculation of the total EPC size, e.g. exposing EPC to guests does not require -maxmem, and last but not least allows all of EPC to be enumerated in a single ACPI entry, which is expected by some kernels, e.g. Windows 7 and 8. The new compound properties command for sgx like below: ...... -object memory-backend-epc,id=3Dmem1,size=3D28M,prealloc=3Don \ -object memory-backend-epc,id=3Dmem2,size=3D10M \ -M sgx-epc.0.memdev=3Dmem1,sgx-epc.1.memdev=3Dmem2 Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-6-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/sgx-epc.c | 20 ++++++++++++++------ hw/i386/x86.c | 29 +++++++++++++++++++++++++++++ include/hw/i386/pc.h | 3 +++ include/hw/i386/sgx-epc.h | 14 ++++++++++++++ include/hw/i386/x86.h | 1 + qapi/machine.json | 26 +++++++++++++++++++++++++- qemu-options.hx | 10 ++++++++-- 7 files changed, 94 insertions(+), 9 deletions(-) diff --git a/hw/i386/sgx-epc.c b/hw/i386/sgx-epc.c index c584acc17b..6677dc74b5 100644 --- a/hw/i386/sgx-epc.c +++ b/hw/i386/sgx-epc.c @@ -14,13 +14,8 @@ #include "hw/i386/sgx-epc.h" #include "hw/mem/memory-device.h" #include "hw/qdev-properties.h" -#include "monitor/qdev.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qemu/config-file.h" -#include "qemu/error-report.h" -#include "qemu/option.h" -#include "qemu/units.h" #include "target/i386/cpu.h" #include "exec/address-spaces.h" =20 @@ -56,6 +51,8 @@ static void sgx_epc_realize(DeviceState *dev, Error **err= p) { PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); X86MachineState *x86ms =3D X86_MACHINE(pcms); + MemoryDeviceState *md =3D MEMORY_DEVICE(dev); + SGXEPCState *sgx_epc =3D &pcms->sgx_epc; SGXEPCDevice *epc =3D SGX_EPC(dev); HostMemoryBackend *hostmem; const char *path; @@ -77,7 +74,18 @@ static void sgx_epc_realize(DeviceState *dev, Error **er= rp) return; } =20 - error_setg(errp, "'" TYPE_SGX_EPC "' not supported"); + epc->addr =3D sgx_epc->base + sgx_epc->size; + + memory_region_add_subregion(&sgx_epc->mr, epc->addr - sgx_epc->base, + host_memory_backend_get_memory(hostmem)); + + host_memory_backend_set_mapped(hostmem, true); + + sgx_epc->sections =3D g_renew(SGXEPCDevice *, sgx_epc->sections, + sgx_epc->nr_sections + 1); + sgx_epc->sections[sgx_epc->nr_sections++] =3D epc; + + sgx_epc->size +=3D memory_device_get_region_size(md, errp); } =20 static void sgx_epc_unrealize(DeviceState *dev) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 00448ed55a..41ef9a84a9 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -30,6 +30,8 @@ #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/qapi-visit-common.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-machine.h" #include "qapi/visitor.h" #include "sysemu/qtest.h" #include "sysemu/whpx.h" @@ -1263,6 +1265,27 @@ static void x86_machine_set_bus_lock_ratelimit(Objec= t *obj, Visitor *v, visit_type_uint64(v, name, &x86ms->bus_lock_ratelimit, errp); } =20 +static void machine_get_sgx_epc(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + X86MachineState *x86ms =3D X86_MACHINE(obj); + SgxEPCList *list =3D x86ms->sgx_epc_list; + + visit_type_SgxEPCList(v, name, &list, errp); +} + +static void machine_set_sgx_epc(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + X86MachineState *x86ms =3D X86_MACHINE(obj); + SgxEPCList *list; + + list =3D x86ms->sgx_epc_list; + visit_type_SgxEPCList(v, name, &x86ms->sgx_epc_list, errp); + + qapi_free_SgxEPCList(list); +} + static void x86_machine_initfn(Object *obj) { X86MachineState *x86ms =3D X86_MACHINE(obj); @@ -1322,6 +1345,12 @@ static void x86_machine_class_init(ObjectClass *oc, = void *data) x86_machine_set_bus_lock_ratelimit, NULL, = NULL); object_class_property_set_description(oc, X86_MACHINE_BUS_LOCK_RATELIM= IT, "Set the ratelimit for the bus locks acquired in VMs"); + + object_class_property_add(oc, "sgx-epc", "SgxEPC", + machine_get_sgx_epc, machine_set_sgx_epc, + NULL, NULL); + object_class_property_set_description(oc, "sgx-epc", + "SGX EPC device"); } =20 static const TypeInfo x86_machine_info =3D { diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 4d2e35a152..668e48be8a 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -12,6 +12,7 @@ #include "hw/acpi/acpi_dev_interface.h" #include "hw/hotplug.h" #include "qom/object.h" +#include "hw/i386/sgx-epc.h" =20 #define HPET_INTCAP "hpet-intcap" =20 @@ -49,6 +50,8 @@ typedef struct PCMachineState { =20 /* ACPI Memory hotplug IO base address */ hwaddr memhp_io_base; + + SGXEPCState sgx_epc; } PCMachineState; =20 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h index cf3ed5c0cd..83269972e0 100644 --- a/include/hw/i386/sgx-epc.h +++ b/include/hw/i386/sgx-epc.h @@ -41,4 +41,18 @@ typedef struct SGXEPCDevice { HostMemoryBackendEpc *hostmem; } SGXEPCDevice; =20 +/* + * @base: address in guest physical address space where EPC regions start + * @mr: address space container for memory devices + */ +typedef struct SGXEPCState { + uint64_t base; + uint64_t size; + + MemoryRegion mr; + + struct SGXEPCDevice **sections; + int nr_sections; +} SGXEPCState; + #endif diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 6e9244a82c..23267a3674 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -62,6 +62,7 @@ struct X86MachineState { unsigned pci_irq_mask; unsigned apic_id_limit; uint16_t boot_cpus; + SgxEPCList *sgx_epc_list; =20 OnOffAuto smm; OnOffAuto acpi; diff --git a/qapi/machine.json b/qapi/machine.json index 32d47f4e35..26c539fe2c 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1225,7 +1225,6 @@ ## { 'struct': 'VirtioMEMDeviceInfoWrapper', 'data': { 'data': 'VirtioMEMDeviceInfo' } } - ## # @MemoryDeviceInfo: # @@ -1246,6 +1245,31 @@ } } =20 +## +# @SgxEPC: +# +# Sgx EPC cmdline information +# +# @memdev: memory backend linked with device +# +# Since: 6.2 +## +{ 'struct': 'SgxEPC', + 'data': { 'memdev': 'str' } } + +## +# @SgxEPCProperties: +# +# SGX properties of machine types. +# +# @sgx-epc: list of ids of memory-backend-epc objects. +# +# Since: 6.2 +## +{ 'struct': 'SgxEPCProperties', + 'data': { 'sgx-epc': ['SgxEPC'] } +} + ## # @query-memory-devices: # diff --git a/qemu-options.hx b/qemu-options.hx index 8f603cc7e6..ceca52818a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -126,8 +126,14 @@ SRST -m 512M ERST =20 -HXCOMM Deprecated by -machine -DEF("M", HAS_ARG, QEMU_OPTION_M, "", QEMU_ARCH_ALL) +DEF("M", HAS_ARG, QEMU_OPTION_M, + " sgx-epc.0.memdev=3Dmemid\n", + QEMU_ARCH_ALL) + +SRST +``sgx-epc.0.memdev=3D@var{memid}`` + Define an SGX EPC section. +ERST =20 DEF("cpu", HAS_ARG, QEMU_OPTION_cpu, "-cpu cpu select CPU ('-cpu help' for list)\n", QEMU_ARCH_ALL) --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163283449425677.84144491882626; Tue, 28 Sep 2021 06:08:14 -0700 (PDT) Received: from localhost ([::1]:37818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCqD-00031X-3n for importer@patchew.org; Tue, 28 Sep 2021 09:08:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0006Ue-4i for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:40 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:44877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0001PV-NJ for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: by mail-ed1-x52e.google.com with SMTP id v18so47485725edc.11 for ; Tue, 28 Sep 2021 05:51:32 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ES28BAOHaA3bl9y4JBGbzrlNr0SK8xxRe1ddZiant8Y=; b=WK4gXtYhvWSPrZTtsF4533HCBtdLA2myBIiIwYp0dW0XwoRgoKwuC4GRF4wxwurQ0+ dPweNC4mWvEPd6DAqE43i3G8UmIBDajX0hsNXXFVpG6HrzfwO03bMSHCcxfqiihpJivc d+jIyiJGpXg8+VeWqmPLzU6DS7X5jSvGcgyjyECTB5+yIdH6WsY9yAcqZArZKJsB3HzF wUbm3/W1IpNsl91UjRklnnsc9nkyneLTO89qd8c/Nb4eotgePwxAAXMIzt9ZBBYyUZrf aJA3GjOLtkdeTMQRJ3lYDZSue0ry3sLP2HxxSGPxJfJK58FwcVtYy9jhRraPNoCmVv2+ PJbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ES28BAOHaA3bl9y4JBGbzrlNr0SK8xxRe1ddZiant8Y=; b=GIMMcUnJTz/0TGSmo/+fBjnDxBE/cV6mZZsn0tcb2LS3MLJMV/6YMx2NNz61IiKm7D Xl7kGnX/iOq5OMmTzB80bAvoJOAPdcDLwjWCOCffQHDga87gHhgwPEZKNnxaaxyqkneJ UJLigRWMb6eFJxEoriyLsYGicIt4yFemHsfgufVcYWm3/jeVbzyft1b3LnI3Xw3X4dGB H16Chuq3kvqiGM/DdJzP+1NDcIwuTo3/V6etpYkoOVF5xpf8UhoZSUmLQe9sZIAipgsb nTuJSbFPVPDpt/fv4g2kzHy9cZr6hRosviomRaYP5Sxy0JWrHovItE3Yxl3/ya26inYE grHw== X-Gm-Message-State: AOAM533MmODRYw4CsMhEgBBIrI2M1UR1rJyms4rgoF7F7XMV63ijTp6Y tIcbp145OW7o3Bn55HyFiz/Y0jP3xgc= X-Google-Smtp-Source: ABdhPJyTrTG4139gmlO9wuhYsNJaRqQnV6aTv74tRACfxsykZAupHwGc5PpUIffvzZL7xwHh7o0pEw== X-Received: by 2002:a17:907:7601:: with SMTP id jx1mr6485137ejc.69.1632833484434; Tue, 28 Sep 2021 05:51:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 07/33] i386: Add primary SGX CPUID and MSR defines Date: Tue, 28 Sep 2021 14:50:50 +0200 Message-Id: <20210928125116.183620-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834495069100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Add CPUID defines for SGX and SGX Launch Control (LC), as well as defines for their associated FEATURE_CONTROL MSR bits. Define the Launch Enclave Public Key Hash MSRs (LE Hash MSRs), which exist when SGX LC is present (in CPUID), and are writable when SGX LC is enabled (in FEATURE_CONTROL). Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-7-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6b029f1bdf..21d2a325ea 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -795,7 +795,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { [FEAT_7_0_EBX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { - "fsgsbase", "tsc-adjust", NULL, "bmi1", + "fsgsbase", "tsc-adjust", "sgx", "bmi1", "hle", "avx2", NULL, "smep", "bmi2", "erms", "invpcid", "rtm", NULL, NULL, "mpx", NULL, @@ -821,7 +821,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL, "bus-lock-detect", "cldemote", NULL, "movdiri", - "movdir64b", NULL, NULL, "pks", + "movdir64b", NULL, "sgxlc", "pks", }, .cpuid =3D { .eax =3D 7, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c2954c71ea..b6491df0f5 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -389,9 +389,17 @@ typedef enum X86Seg { #define MSR_IA32_PKRS 0x6e1 =20 #define FEATURE_CONTROL_LOCKED (1<<0) +#define FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX (1ULL << 1) #define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1<<2) +#define FEATURE_CONTROL_SGX_LC (1ULL << 17) +#define FEATURE_CONTROL_SGX (1ULL << 18) #define FEATURE_CONTROL_LMCE (1<<20) =20 +#define MSR_IA32_SGXLEPUBKEYHASH0 0x8c +#define MSR_IA32_SGXLEPUBKEYHASH1 0x8d +#define MSR_IA32_SGXLEPUBKEYHASH2 0x8e +#define MSR_IA32_SGXLEPUBKEYHASH3 0x8f + #define MSR_P6_PERFCTR0 0xc1 =20 #define MSR_IA32_SMBASE 0x9e @@ -718,6 +726,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; =20 /* Support RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */ #define CPUID_7_0_EBX_FSGSBASE (1U << 0) +/* Support SGX */ +#define CPUID_7_0_EBX_SGX (1U << 2) /* 1st Group of Advanced Bit Manipulation Extensions */ #define CPUID_7_0_EBX_BMI1 (1U << 3) /* Hardware Lock Elision */ @@ -805,6 +815,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_7_0_ECX_MOVDIRI (1U << 27) /* Move 64 Bytes as Direct Store Instruction */ #define CPUID_7_0_ECX_MOVDIR64B (1U << 28) +/* Support SGX Launch Control */ +#define CPUID_7_0_ECX_SGX_LC (1U << 30) /* Protection Keys for Supervisor-mode Pages */ #define CPUID_7_0_ECX_PKS (1U << 31) =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834276201157.05062882558536; Tue, 28 Sep 2021 06:04:36 -0700 (PDT) Received: from localhost ([::1]:56716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCmg-00055k-9u for importer@patchew.org; Tue, 28 Sep 2021 09:04:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0006Oq-Vq for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:34 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:37538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa3-0001OO-Js for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:32 -0400 Received: by mail-ed1-x52d.google.com with SMTP id ba1so24896014edb.4 for ; Tue, 28 Sep 2021 05:51:31 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vIZhtxRfpLD3As3rA5Gn2uhFgwLP60EEjiPbzW6gvTs=; b=fIuyGEC+290iYNf+wnJdzfIkdgk1+FG+6JUqcJPb9pC2gfoAe7r+AGma0XCSlxV9gw SnS+jEPmk0Of6h/LaPz9LA5eKuMwNeIFWpe1yUNn1rN3/ozijHdyVuCDsyyOGl37qkZ7 1zd8ZdyTewiAyOI9JQZJ2MPLosBPPHQZyPc4HKli8voWHOfFVOVaOUdnOZWMQAZt8I+a u4sVx/hDYV+CO1oQt6MrCfA4q7h20Ur6f8sCRUNsvG5znrRGPWD6Tzhhz2waCTjUHXnl cNvR+KAryF/vvVD45C4HuIB3H3R/97+8UZKxW4aq7PXoLkqoQgRsDYoyxi6qlG6NDCgS OGkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vIZhtxRfpLD3As3rA5Gn2uhFgwLP60EEjiPbzW6gvTs=; b=3eznOxOdgOJfYZfLleoJLQawU/zGxpPAR7szuYuPhQ/ER/bjK3311XVGETHeb1rF/+ tJ9L+gToJ/9BcHns/hqTtXVsdyYSvceEvVTlVgkPAmzqw5RD5Y8dpE3Bta8mBv3PYHbI TnToZNB8EJ8/ikY0hyehG1Qf3DmBFWmsfzEoETZ8fMaUQq846XnK53/R6ENs/9tg9i9u Uq9iiM2fLjYouSnWJsMvMD1sPZJqnlV/CMRTgLiotRFDQkV3xaHDxClUiIP0/nNbjOEu l37Yx9J5jMbh1w55LfYFKoA98Gc5UgQWzZWDVZODbtoCuDcJ82YSZeGFte7c5KqqGdXR R4mQ== X-Gm-Message-State: AOAM531xtwFHhibM5QIUG7LkaUN9e3FA4Ucye7bhwkwkU0RyElPTDRUx 9wWhLToEafS2+JbQ0I3Ppkdj64OqQWE= X-Google-Smtp-Source: ABdhPJzDqUvSWnTkHHa4jOwxrYjgMIsj443eWJ5kY8enoGInCWd1f6eJumUFFu6JOfeT3EtoQqOYVQ== X-Received: by 2002:a17:906:9742:: with SMTP id o2mr6586851ejy.532.1632833485339; Tue, 28 Sep 2021 05:51:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 08/33] i386: Add SGX CPUID leaf FEAT_SGX_12_0_EAX Date: Tue, 28 Sep 2021 14:50:51 +0200 Message-Id: <20210928125116.183620-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834284220100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson CPUID leaf 12_0_EAX is an Intel-defined feature bits leaf enumerating the CPU's SGX capabilities, e.g. supported SGX instruction sets. Currently there are four enumerated capabilities: - SGX1 instruction set, i.e. "base" SGX - SGX2 instruction set for dynamic EPC management - ENCLV instruction set for VMM oversubscription of EPC - ENCLS-C instruction set for thread safe variants of ENCLS Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-8-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 20 ++++++++++++++++++++ target/i386/cpu.h | 1 + 2 files changed, 21 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 21d2a325ea..2cd1487bae 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -654,6 +654,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, /* missing: CPUID_XSAVE_XSAVEC, CPUID_XSAVE_XSAVES */ #define TCG_14_0_ECX_FEATURES 0 +#define TCG_SGX_12_0_EAX_FEATURES 0 =20 FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { [FEAT_1_EDX] =3D { @@ -1182,6 +1183,25 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { .tcg_features =3D TCG_14_0_ECX_FEATURES, }, =20 + [FEAT_SGX_12_0_EAX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + "sgx1", "sgx2", 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, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid =3D { + .eax =3D 0x12, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EAX, + }, + .tcg_features =3D TCG_SGX_12_0_EAX_FEATURES, + }, }; =20 typedef struct FeatureMask { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b6491df0f5..2b199102ef 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -578,6 +578,7 @@ typedef enum FeatureWord { FEAT_VMX_BASIC, FEAT_VMX_VMFUNC, FEAT_14_0_ECX, + FEAT_SGX_12_0_EAX, /* CPUID[EAX=3D0x12,ECX=3D0].EAX (SGX) */ FEATURE_WORDS, } FeatureWord; =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834655602513.3924414513372; Tue, 28 Sep 2021 06:10:55 -0700 (PDT) Received: from localhost ([::1]:42836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCsn-0006Ti-2N for importer@patchew.org; Tue, 28 Sep 2021 09:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0006Op-Tc for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:34 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:47093) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa3-0001O4-F1 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:32 -0400 Received: by mail-ed1-x52a.google.com with SMTP id dn26so5833496edb.13 for ; Tue, 28 Sep 2021 05:51:31 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/5WRUTjHtjEWTz69+uuhMgTteeRSS/ZjOYxvuLAzQ0E=; b=UDghGXKMV4tnra6Ko1KcR2KdB/3XP9tB7ZbxDwoa8AGOm3ISLchEo7qGM6zH/PKY5C zuhjfK4KmT9H4H+hkPsWa/TRmo+nkn99LjIcEi/gwkVgxY2COe2K4Smz4wap/tyWNXGW xHh+l9ZkVFk++aXNJiLIORVeo+lnb4Gsooahrchfv9gIUBvzKiYLXGM0yHaued8XgF/a GR6fLfLdAyh/gZodZyrl2TFFeULOhQJwMjHND3U1fFsiq4xBuL992yyuhsvIW7tKs2tX G+1RVPDPrlvyldd/9zHsCvJiTsPjTu4Wyu5FPSZGBpjdU1QUN71ZrZUvsDP0ixffHc74 wtVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/5WRUTjHtjEWTz69+uuhMgTteeRSS/ZjOYxvuLAzQ0E=; b=WEtQ5T2FlbWphBtczTVQo4LZHSIjiLgShl9lfohvG/Q6nEt56TWXZ2MwO/YGodZyak bv4yE0yA6MLgO8/8RlM0d+RHNmtjWPz7Qzm+FEqRATpf0vPS7FhbYz03M4JE9+zXEeB0 jVWaW0vtuOCoK6VuHnf/1fa9ClD7f7P0+z4YLRQ4QoYzqATUugEJnBaQH1P1rVF92+4l BbLhWTDB2fEcTc6J6OEfbZTLbm3ya6xN+9OIJ375xjR2ubKo3to7++IO/OmSVu5SRYmT hkU+0ax4RzX1mfVjd1T83ckc4Ug3rG/sehEVOhUUG4oNDv9Y3i64hCIn1IQLdY7VV/28 URyA== X-Gm-Message-State: AOAM533cesPsNHvXbcHfjz+CS/GJk96XPs71aUDcrm5OAiPbZto4tnDo GLeu1VRDlRFtVPZsH/aGzsIf5goVYZo= X-Google-Smtp-Source: ABdhPJyci7ENtz4cX+gbU/oOH++gD4Qi56o8HZASLvmTgYs0K3c+ZmpZYOg4AlyXQ69cB0ikp7CjOw== X-Received: by 2002:a17:906:700f:: with SMTP id n15mr6378789ejj.319.1632833486096; Tue, 28 Sep 2021 05:51:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/33] i386: Add SGX CPUID leaf FEAT_SGX_12_0_EBX Date: Tue, 28 Sep 2021 14:50:52 +0200 Message-Id: <20210928125116.183620-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834662477100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson CPUID leaf 12_0_EBX is an Intel-defined feature bits leaf enumerating the platform's SGX extended capabilities. Currently there is a single capabilitiy: - EXINFO: record information about #PFs and #GPs in the enclave's SSA Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-9-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 21 +++++++++++++++++++++ target/i386/cpu.h | 1 + 2 files changed, 22 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2cd1487bae..c0d5c3c621 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -655,6 +655,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, CPUID_XSAVE_XSAVEC, CPUID_XSAVE_XSAVES */ #define TCG_14_0_ECX_FEATURES 0 #define TCG_SGX_12_0_EAX_FEATURES 0 +#define TCG_SGX_12_0_EBX_FEATURES 0 =20 FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { [FEAT_1_EDX] =3D { @@ -1202,6 +1203,26 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { }, .tcg_features =3D TCG_SGX_12_0_EAX_FEATURES, }, + + [FEAT_SGX_12_0_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + "sgx-exinfo" , 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, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid =3D { + .eax =3D 0x12, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EBX, + }, + .tcg_features =3D TCG_SGX_12_0_EBX_FEATURES, + }, }; =20 typedef struct FeatureMask { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 2b199102ef..e66ec85980 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -579,6 +579,7 @@ typedef enum FeatureWord { FEAT_VMX_VMFUNC, FEAT_14_0_ECX, FEAT_SGX_12_0_EAX, /* CPUID[EAX=3D0x12,ECX=3D0].EAX (SGX) */ + FEAT_SGX_12_0_EBX, /* CPUID[EAX=3D0x12,ECX=3D0].EBX (SGX MISCSELECT[3= 1:0]) */ FEATURE_WORDS, } FeatureWord; =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834478600616.7229079744054; Tue, 28 Sep 2021 06:07:58 -0700 (PDT) Received: from localhost ([::1]:37184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCpx-0002ZR-Jm for importer@patchew.org; Tue, 28 Sep 2021 09:07:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa7-0006QC-8v for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:47099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0001Oi-Gc for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:34 -0400 Received: by mail-ed1-x530.google.com with SMTP id dn26so5833596edb.13 for ; Tue, 28 Sep 2021 05:51:31 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xFlr8+Eokp+7BRksYfbdcbnVTGvQvuKTlVLPTcOMOIw=; b=M8jLWOk4DrHGAEfxMVWQTc1goRf/C2T8iDrwb41hzWIBIY6OQ+582w5Pg/jvJXgkj6 m6b9pkVrBffXk51yusUYa4zgW+2o1VWJMxMvH2QYH/akrNK3auvxmiF6vdbW+GYd/Zde FXCkLlWn7u1zhReJNepuk3AhxL+7ILkDLC21iStWydeApoQZGVIzE2rkaxhGj5t3qVLS gXEzX/w266teyu8RVF2XIo0ZtCP7q+2Na3ujNENPYprREHYQDDxuT/Fu5er1hs/3JxMJ p0yfDKJGYnc+b344gYfVIlBeChiImiY6I5keITVXxGoXhcPBjfbDz7Dys8c3dVcM7U6e B9VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xFlr8+Eokp+7BRksYfbdcbnVTGvQvuKTlVLPTcOMOIw=; b=xuFGFuXcdXJPH8sdeMecqNpC9hNybzcdQrApmV7V70P8ZgG+KULHriRVbxfPcnOUhh FKDohZfB/4gdjyp9iCJnyW3FhMY6d2yjF7ng0LJwoLiCUa+U5U6vMWOLBdQ9UOK5l2NJ ccJr4Org4jgefZ8l1KhLJALCX7TtaC4rWdb274ejVWMW/v+RcS3qC0eJHIvc/xMmseWx 1QHE5d0jU2oQXab+TTEEluV83kAZXDLUROmzy0gIe1wtdbi65MU5DhZGsYKCgpVf6QHn 1T/Mj5xlLyam1HkdroA7zb7Bhkx+4AdihFvCE3ULJcWGzaDMsl171y+aGLKt6MX5YyQ2 gDOw== X-Gm-Message-State: AOAM530YV2lEYbiBvM0gmFCrmwh96VFmRlE5yQGSrZs97PE28tYmNvcE 07r1Y1NmRcUHMc//qURZ5wWnahyVKx4= X-Google-Smtp-Source: ABdhPJza33U3TI/5SFWLcJK1VwrktcrGdl7zl6O125JTMMbOISBBidRenwPF1BUVzigjZijiYHTwGQ== X-Received: by 2002:a17:906:645:: with SMTP id t5mr6483266ejb.163.1632833486792; Tue, 28 Sep 2021 05:51:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/33] i386: Add SGX CPUID leaf FEAT_SGX_12_1_EAX Date: Tue, 28 Sep 2021 14:50:53 +0200 Message-Id: <20210928125116.183620-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834479641100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson CPUID leaf 12_1_EAX is an Intel-defined feature bits leaf enumerating the platform's SGX capabilities that may be utilized by an enclave, e.g. whether or not an enclave can gain access to the provision key. Currently there are six capabilities: - INIT: set when the enclave has has been initialized by EINIT. Cannot be set by software, i.e. forced to zero in CPUID. - DEBUG: permits a debugger to read/write into the enclave. - MODE64BIT: the enclave runs in 64-bit mode - PROVISIONKEY: grants has access to the provision key - EINITTOKENKEY: grants access to the EINIT token key, i.e. the enclave can generate EINIT tokens - KSS: Key Separation and Sharing enabled for the enclave. Note that the entirety of CPUID.0x12.0x1, i.e. all registers, enumerates the allowed ATTRIBUTES (128 bits), but only bits 31:0 are directly exposed to the user (via FEAT_12_1_EAX). Bits 63:32 are currently all reserved and bits 127:64 correspond to the allowed XSAVE Feature Request Mask, which is calculated based on other CPU features, e.g. XSAVE, MPX, AVX, etc... and is not exposed to the user. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-10-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 21 +++++++++++++++++++++ target/i386/cpu.h | 1 + 2 files changed, 22 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c0d5c3c621..e9ecbf59e5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -656,6 +656,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, #define TCG_14_0_ECX_FEATURES 0 #define TCG_SGX_12_0_EAX_FEATURES 0 #define TCG_SGX_12_0_EBX_FEATURES 0 +#define TCG_SGX_12_1_EAX_FEATURES 0 =20 FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { [FEAT_1_EDX] =3D { @@ -1223,6 +1224,26 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { }, .tcg_features =3D TCG_SGX_12_0_EBX_FEATURES, }, + + [FEAT_SGX_12_1_EAX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + NULL, "sgx-debug", "sgx-mode64", NULL, + "sgx-provisionkey", "sgx-tokenkey", NULL, "sgx-kss", + 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 =3D { + .eax =3D 0x12, + .needs_ecx =3D true, .ecx =3D 1, + .reg =3D R_EAX, + }, + .tcg_features =3D TCG_SGX_12_1_EAX_FEATURES, + }, }; =20 typedef struct FeatureMask { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e66ec85980..85a9eeeb2b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -580,6 +580,7 @@ typedef enum FeatureWord { FEAT_14_0_ECX, FEAT_SGX_12_0_EAX, /* CPUID[EAX=3D0x12,ECX=3D0].EAX (SGX) */ FEAT_SGX_12_0_EBX, /* CPUID[EAX=3D0x12,ECX=3D0].EBX (SGX MISCSELECT[3= 1:0]) */ + FEAT_SGX_12_1_EAX, /* CPUID[EAX=3D0x12,ECX=3D1].EAX (SGX ATTRIBUTES[3= 1:0]) */ FEATURE_WORDS, } FeatureWord; =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835182636480.34403654401876; Tue, 28 Sep 2021 06:19:42 -0700 (PDT) Received: from localhost ([::1]:35554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD1J-000426-L1 for importer@patchew.org; Tue, 28 Sep 2021 09:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaD-0006XZ-3k for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:44 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:36731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0001Ph-N9 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: by mail-ed1-x532.google.com with SMTP id y35so31709359ede.3 for ; Tue, 28 Sep 2021 05:51:32 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3G4/DFX1r/a1570OxD1emO3ZLWAbs3gE4VJKE7B8FXM=; b=OlJPvTlGzFow/ErpIDaXiGn3ai3d2IqMfYGW/cPxXBvol9Cvs5bZsN2NpfhU51gM7j O+TuUvRrzV+EDwh6+s+T3RS6Qh1rXsvgrVrtZlmEzZ9/hlvWo/ElqnqdW7ymqxmNPa2e K4NspEB709x3cZLqkWnOfKGRx73pOs29xrdzrkitqf+HseFDZKthlSZ9+Ukuqy7ArYK4 rUug6W4jv7siFnZ8cAuf+aE4LYmnw1UbUfoRRV6b5YfprtzMnzzcGlB0bi3xkrIavQcX pvuXVnqn4lhk5W0YI5mn9Ld4UPfFbJ7J14ljW12bMq3OO0/0gAvP92W+qu+S4w8scBK2 3Gvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3G4/DFX1r/a1570OxD1emO3ZLWAbs3gE4VJKE7B8FXM=; b=xdk3ZqvYu4ru75/sigFrIqWuSH0TZFKByQVCj6gStZDT/1xxf5KD00PLd4P7/T9CBV aebqqEKRtrP17kZpEUrTKt3UDPoxfNgILH1kp0enzXeNy6FXuTePu88es9OgE6/7FSMY KOVJikf2RarF3oI/u4iNTYngIWhOmVj+vaSVBcMFUlKUGjcw5Uju80KJvK5MJSyuq4pN 56pcTq1EzMD7GBbPlQFMkM3G2t0LeCH2UqNZKTKa5d9AITSr0G1qepUv62BfgBbQhtZE E6xvxQ2HU+Po3w/0x31/bgfYDnNxkC8b7WId9NwhMyrLAmsUmDvAKqTxDbraPaxv2D36 AepQ== X-Gm-Message-State: AOAM5306mm7v2fOz6CM8Nqgcx3gbJdZGE4EcPERcV9iKR2XsQIlxr4rg VsAfjdXycDkvdZKltJfsIAV3rFT0dv4= X-Google-Smtp-Source: ABdhPJx54QsB06wqbf4Y1B26ZxIb+/LyAXL70xuWivOaJn8vhG05aTEpfki9FZGOKK1XLBSBNhNAFQ== X-Received: by 2002:a17:906:2613:: with SMTP id h19mr6746684ejc.66.1632833487520; Tue, 28 Sep 2021 05:51:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/33] i386: Add get/set/migrate support for SGX_LEPUBKEYHASH MSRs Date: Tue, 28 Sep 2021 14:50:54 +0200 Message-Id: <20210928125116.183620-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Kai Huang , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835183732100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson On real hardware, on systems that supports SGX Launch Control, those MSRs are initialized to digest of Intel's signing key; on systems that don't support SGX Launch Control, those MSRs are not available but hardware always uses digest of Intel's signing key in EINIT. KVM advertises SGX LC via CPUID if and only if the MSRs are writable. Unconditionally initialize those MSRs to digest of Intel's signing key when CPU is realized and reset to reflect the fact. This avoids potential bug in case kvm_arch_put_registers() is called before kvm_arch_get_registers() is called, in which case guest's virtual SGX_LEPUBKEYHASH MSRs will be set to 0, although KVM initializes those to digest of Intel's signing key by default, since KVM allows those MSRs to be updated by Qemu to support live migration. Save/restore the SGX Launch Enclave Public Key Hash MSRs if SGX Launch Control (LC) is exposed to the guest. Likewise, migrate the MSRs if they are writable by the guest. Signed-off-by: Sean Christopherson Signed-off-by: Kai Huang Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-11-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 16 +++++++++++++++- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 22 ++++++++++++++++++++++ target/i386/machine.c | 20 ++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e9ecbf59e5..af6cd73eed 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5700,6 +5700,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, } } =20 +static void x86_cpu_set_sgxlepubkeyhash(CPUX86State *env) +{ +#ifndef CONFIG_USER_ONLY + /* Those default values are defined in Skylake HW */ + env->msr_ia32_sgxlepubkeyhash[0] =3D 0xa6053e051270b7acULL; + env->msr_ia32_sgxlepubkeyhash[1] =3D 0x6cfbe8ba8b3b413dULL; + env->msr_ia32_sgxlepubkeyhash[2] =3D 0xc4916d99f2b3735dULL; + env->msr_ia32_sgxlepubkeyhash[3] =3D 0xd4f8c05909f9bb3bULL; +#endif +} + static void x86_cpu_reset(DeviceState *dev) { CPUState *s =3D CPU(dev); @@ -5832,6 +5843,8 @@ static void x86_cpu_reset(DeviceState *dev) if (kvm_enabled()) { kvm_arch_reset_vcpu(cpu); } + + x86_cpu_set_sgxlepubkeyhash(env); #endif } =20 @@ -6214,6 +6227,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) & CPUID_EXT2_AMD_ALIASES); } =20 + x86_cpu_set_sgxlepubkeyhash(env); + /* * note: the call to the framework needs to happen after feature expan= sion, * but before the checks/modifications to ucode_rev, mwait, phys_bits. @@ -6901,7 +6916,6 @@ static const TypeInfo x86_cpu_type_info =3D { .class_init =3D x86_cpu_common_class_init, }; =20 - /* "base" CPU model, used by query-cpu-model-expansion */ static void x86_cpu_base_class_init(ObjectClass *oc, void *data) { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 85a9eeeb2b..29552dc2a7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1516,6 +1516,7 @@ typedef struct CPUX86State { uint64_t mcg_status; uint64_t msr_ia32_misc_enable; uint64_t msr_ia32_feature_control; + uint64_t msr_ia32_sgxlepubkeyhash[4]; =20 uint64_t msr_fixed_ctr_ctrl; uint64_t msr_global_ctrl; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 500d2e0e68..11551648f9 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3107,6 +3107,17 @@ static int kvm_put_msrs(X86CPU *cpu, int level) } } =20 + if (env->features[FEAT_7_0_ECX] & CPUID_7_0_ECX_SGX_LC) { + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH0, + env->msr_ia32_sgxlepubkeyhash[0]); + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH1, + env->msr_ia32_sgxlepubkeyhash[1]); + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH2, + env->msr_ia32_sgxlepubkeyhash[2]); + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH3, + env->msr_ia32_sgxlepubkeyhash[3]); + } + /* Note: MSR_IA32_FEATURE_CONTROL is written separately, see * kvm_put_msr_feature_control. */ } @@ -3446,6 +3457,13 @@ static int kvm_get_msrs(X86CPU *cpu) } } =20 + if (env->features[FEAT_7_0_ECX] & CPUID_7_0_ECX_SGX_LC) { + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH0, 0); + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH1, 0); + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH2, 0); + kvm_msr_entry_add(cpu, MSR_IA32_SGXLEPUBKEYHASH3, 0); + } + ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, cpu->kvm_msr_buf); if (ret < 0) { return ret; @@ -3735,6 +3753,10 @@ static int kvm_get_msrs(X86CPU *cpu) case MSR_IA32_RTIT_ADDR0_A ... MSR_IA32_RTIT_ADDR3_B: env->msr_rtit_addrs[index - MSR_IA32_RTIT_ADDR0_A] =3D msrs[i]= .data; break; + case MSR_IA32_SGXLEPUBKEYHASH0 ... MSR_IA32_SGXLEPUBKEYHASH3: + env->msr_ia32_sgxlepubkeyhash[index - MSR_IA32_SGXLEPUBKEYHASH= 0] =3D + msrs[i].data; + break; } } =20 diff --git a/target/i386/machine.c b/target/i386/machine.c index b0943118d1..4367931623 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -1415,6 +1415,25 @@ static const VMStateDescription vmstate_msr_tsx_ctrl= =3D { } }; =20 +static bool intel_sgx_msrs_needed(void *opaque) +{ + X86CPU *cpu =3D opaque; + CPUX86State *env =3D &cpu->env; + + return !!(env->features[FEAT_7_0_ECX] & CPUID_7_0_ECX_SGX_LC); +} + +static const VMStateDescription vmstate_msr_intel_sgx =3D { + .name =3D "cpu/intel_sgx", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D intel_sgx_msrs_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64_ARRAY(env.msr_ia32_sgxlepubkeyhash, X86CPU, 4), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_x86_cpu =3D { .name =3D "cpu", .version_id =3D 12, @@ -1551,6 +1570,7 @@ const VMStateDescription vmstate_x86_cpu =3D { &vmstate_nested_state, #endif &vmstate_msr_tsx_ctrl, + &vmstate_msr_intel_sgx, NULL } }; --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834976905257.32064359004426; Tue, 28 Sep 2021 06:16:16 -0700 (PDT) Received: from localhost ([::1]:54158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCxz-0005qs-N1 for importer@patchew.org; Tue, 28 Sep 2021 09:16:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0006Uh-5r for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:40 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:37537) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa6-0001Q6-LO for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:37 -0400 Received: by mail-ed1-x52b.google.com with SMTP id ba1so24896445edb.4 for ; Tue, 28 Sep 2021 05:51:34 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5r01uT4tR8NNg495M2MrgoZZ94BYOI+Ryf0JV3pSQkM=; b=NmJ6uPj2uGCH7dcrLpA+fVWIEy7v4ciwyjKRAg3GN4XFiTqfamN4RysNz3JEfe9QK5 ju1i5FlgY2TcwR0n3wcA/UUAcN5iqBgSt+e5ywcOWBdZatw+PzMwUg62aNBo6bX3eJO0 xwLKC2MYIkwY4lAFyn/CWX3+VsjmMvmn0phDoOpRzryJiANxQOrFLQ1/FmDdxuDxTkTX 3VXDAv4efwZj6R2M9o7HHvGV4SZTyS7KG9TDvFzpUeFRMPD5il+eXBX3CTKbt0nwtZ3V WSFilfIurxiLsxA67ONenJu9Yhv34v+xRv645+4QsA8cd7a0LbtsVG3UtSCyVUS2EZdQ tw2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=5r01uT4tR8NNg495M2MrgoZZ94BYOI+Ryf0JV3pSQkM=; b=1mSjGHnR5WRlOet1v5DZncEVri6aIjQR87wP1qpi8mgrSfjs2c6HAjbRDH5hFArazG /jGTmVlVNkVIXpYI4Ew/NOLtYeze8BSbwCO5huxZVFDA7WSfiEd+Y+6S1JeVwHLLU2Pr WUfN1h494RZ+4WMc6BGuXaHSecPcATGUjg99kBHlsK9idH3HN9soEXum6QYTu1OLqBrJ m0gsSxpKBnbxN9iSDAiYx03tanRVtrDeJJypIWIm8m8lrtte4QoJiT81xfTErKplz3dY CRDG1gDOHHy18pxC1vPS8ToVSC6UIpOk53MSaERwTb3oOxaiJibsn31oXKlxUXDQOpnX uktQ== X-Gm-Message-State: AOAM53111G42Nn8xQ5afijaRqg0jQiyNLNhzdKuiPLXTIx0+b3GXZmkI S3DWHVmY4uM+eAfXqmFvOh5mMiGKu5A= X-Google-Smtp-Source: ABdhPJxBtlgQKfRpA9V1m3EJeeCHB26nwgfV+qibPPzFQRGImJ79Q9QfdVrlJrBWg8MjBH52pHNOkA== X-Received: by 2002:a17:906:114f:: with SMTP id i15mr6300918eja.124.1632833488167; Tue, 28 Sep 2021 05:51:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/33] i386: Add feature control MSR dependency when SGX is enabled Date: Tue, 28 Sep 2021 14:50:55 +0200 Message-Id: <20210928125116.183620-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834977652100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson SGX adds multiple flags to FEATURE_CONTROL to enable SGX and Flexible Launch Control. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-12-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 11551648f9..6dc40161e0 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1877,6 +1877,11 @@ int kvm_arch_init_vcpu(CPUState *cs) !!(c->ecx & CPUID_EXT_SMX); } =20 + c =3D cpuid_find_entry(&cpuid_data.cpuid, 7, 0); + if (c && (c->ebx & CPUID_7_0_EBX_SGX)) { + has_msr_feature_control =3D true; + } + if (env->mcg_cap & MCG_LMCE_P) { has_msr_mcg_ext_ctl =3D has_msr_feature_control =3D true; } --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834990531472.143690293104; Tue, 28 Sep 2021 06:16:30 -0700 (PDT) Received: from localhost ([::1]:55024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCyD-0006Wc-6a for importer@patchew.org; Tue, 28 Sep 2021 09:16:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0006Ul-6M for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:40 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:38410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0001PU-U0 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: by mail-ed1-x52e.google.com with SMTP id dj4so83098296edb.5 for ; Tue, 28 Sep 2021 05:51:33 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ckm63rG6PrQKNaZYx9GzsYEPnaX0K6c7bQ2QgLspzxc=; b=BRAlg+sGgNTMW7tlnc1kPeeWxxOCwHcZW3Vgidmr5MHWvlsQ94JfT9qKHxsqaX7qUk tpnaX/ulSE/ANEIZ1yYrbZidP510RM1HWEkGob6ULYqyea6fj45oFnMQE5NNktsYbGdO 6jpOhEavyhVegAio1ZBKXDrfmBHMVFGWd6qg0zrPHDh5eINRAaPby3zd3axjNsw+HTiU s6ob86bK1RP+salr/2O1fQj2JCcV0ShuFxPbQbt0azUWi7oVjzmip2h+1WiQCB8wp+JX xIoN2Bpl/ENYAKPrCGFykpGrrns+H9IsCVf+7P1pVs4llkOtXe9ymONvws4AIBpJZ4HE EiLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ckm63rG6PrQKNaZYx9GzsYEPnaX0K6c7bQ2QgLspzxc=; b=oDv6bwRpXNn+e7T5RjyUjSFiWUJXR8/oP4B7twPqnx9ET8Nk5Qx20K/pQhuSgYcnlj 4dXq/ZfFVw3dn/3TYQh+ULBMX8MG8HUQgXwTGiLXNNj3955fwHBlGmxKIszeFhkVs6CU m70MZKFTRg4rocUBjeAAq5DtvOf3t4W3TJm3n85F2uThpdg6nkTqaIC/YWPJbU6AKV0x wloX6+XCrh+X3xen4Uf08yonVIfFLWazHk5oyw4ZKs7zthhMoLAVTZdPBeOdPQ2Bki5x M0I8Oq2SkN8lRA7HdTuPbjnGGF65F2NMwNmwg2UcE7HcrLWf+hwzfjZ4Yotf1zAFWhtE nQJQ== X-Gm-Message-State: AOAM531k2xQHXNOvyO/E4LKijlE7RRuIEyE++QUbcOMymjnzCnLQoCfL xtYaNbElElwn39cPoMJz7sJIFCx5K8w= X-Google-Smtp-Source: ABdhPJy0RePVaIZA9WvDrJ32FZGJ4FooT5cdfOSk8pXTRJy134Qr0T3hX+l30AnBcDFvYivwpeU4yw== X-Received: by 2002:a17:906:bfe7:: with SMTP id vr7mr6522729ejb.32.1632833488943; Tue, 28 Sep 2021 05:51:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/33] i386: Update SGX CPUID info according to hardware/KVM/user input Date: Tue, 28 Sep 2021 14:50:56 +0200 Message-Id: <20210928125116.183620-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834992364100003 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Expose SGX to the guest if and only if KVM is enabled and supports virtualization of SGX. While the majority of ENCLS can be emulated to some degree, because SGX uses a hardware-based root of trust, the attestation aspects of SGX cannot be emulated in software, i.e. ultimately emulation will fail as software cannot generate a valid quote/report. The complexity of partially emulating SGX in Qemu far outweighs the value added, e.g. an SGX specific simulator for userspace applications can emulate SGX for development and testing purposes. Note, access to the PROVISIONKEY is not yet advertised to the guest as KVM blocks access to the PROVISIONKEY by default and requires userspace to provide additional credentials (via ioctl()) to expose PROVISIONKEY. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-13-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/meson.build | 3 +- hw/i386/sgx-stub.c | 13 +++++++ hw/i386/sgx.c | 73 +++++++++++++++++++++++++++++++++++++ include/hw/i386/pc.h | 3 ++ include/hw/i386/sgx-epc.h | 2 + target/i386/cpu.c | 77 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 hw/i386/sgx-stub.c create mode 100644 hw/i386/sgx.c diff --git a/hw/i386/meson.build b/hw/i386/meson.build index b1862c83d4..c502965219 100644 --- a/hw/i386/meson.build +++ b/hw/i386/meson.build @@ -16,7 +16,8 @@ i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c'= )) i386_ss.add(when: 'CONFIG_VMMOUSE', if_true: files('vmmouse.c')) i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport.c')) i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c')) -i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c')) +i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'), + if_false: files('sgx-stub.c')) =20 i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c')) i386_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_= device_x86.c')) diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c new file mode 100644 index 0000000000..483c72bba6 --- /dev/null +++ b/hw/i386/sgx-stub.c @@ -0,0 +1,13 @@ +#include "qemu/osdep.h" +#include "hw/i386/pc.h" +#include "hw/i386/sgx-epc.h" + +void pc_machine_init_sgx_epc(PCMachineState *pcms) +{ + memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState)); +} + +int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) +{ + g_assert_not_reached(); +} diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c new file mode 100644 index 0000000000..8a18cddc3f --- /dev/null +++ b/hw/i386/sgx.c @@ -0,0 +1,73 @@ +/* + * SGX common code + * + * Copyright (C) 2021 Intel Corporation + * + * Authors: + * Yang Zhong + * Sean Christopherson + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "hw/i386/pc.h" +#include "hw/i386/sgx-epc.h" +#include "hw/mem/memory-device.h" +#include "monitor/qdev.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" + +int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) +{ + PCMachineState *pcms =3D PC_MACHINE(qdev_get_machine()); + SGXEPCDevice *epc; + + if (pcms->sgx_epc.size =3D=3D 0 || pcms->sgx_epc.nr_sections <=3D sect= ion_nr) { + return 1; + } + + epc =3D pcms->sgx_epc.sections[section_nr]; + + *addr =3D epc->addr; + *size =3D memory_device_get_region_size(MEMORY_DEVICE(epc), &error_fat= al); + + return 0; +} + +void pc_machine_init_sgx_epc(PCMachineState *pcms) +{ + SGXEPCState *sgx_epc =3D &pcms->sgx_epc; + X86MachineState *x86ms =3D X86_MACHINE(pcms); + SgxEPCList *list =3D NULL; + Object *obj; + + memset(sgx_epc, 0, sizeof(SGXEPCState)); + if (!x86ms->sgx_epc_list) { + return; + } + + sgx_epc->base =3D 0x100000000ULL + x86ms->above_4g_mem_size; + + memory_region_init(&sgx_epc->mr, OBJECT(pcms), "sgx-epc", UINT64_MAX); + memory_region_add_subregion(get_system_memory(), sgx_epc->base, + &sgx_epc->mr); + + for (list =3D x86ms->sgx_epc_list; list; list =3D list->next) { + obj =3D object_new("sgx-epc"); + + /* set the memdev link with memory backend */ + object_property_parse(obj, SGX_EPC_MEMDEV_PROP, list->value->memde= v, + &error_fatal); + object_property_set_bool(obj, "realized", true, &error_fatal); + object_unref(obj); + } + + if ((sgx_epc->base + sgx_epc->size) < sgx_epc->base) { + error_report("Size of all 'sgx-epc' =3D0x%"PRIu64" causes EPC to w= rap", + sgx_epc->size); + exit(EXIT_FAILURE); + } + + memory_region_set_size(&sgx_epc->mr, sgx_epc->size); +} diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 668e48be8a..5748d7c55f 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -195,6 +195,9 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, siz= e_t flash_size); void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry); =20 +/* sgx.c */ +void pc_machine_init_sgx_epc(PCMachineState *pcms); + extern GlobalProperty pc_compat_6_1[]; extern const size_t pc_compat_6_1_len; =20 diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h index 83269972e0..75b19f464c 100644 --- a/include/hw/i386/sgx-epc.h +++ b/include/hw/i386/sgx-epc.h @@ -55,4 +55,6 @@ typedef struct SGXEPCState { int nr_sections; } SGXEPCState; =20 +int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size); + #endif diff --git a/target/i386/cpu.c b/target/i386/cpu.c index af6cd73eed..8a62986819 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -36,6 +36,7 @@ #ifndef CONFIG_USER_ONLY #include "exec/address-spaces.h" #include "hw/boards.h" +#include "hw/i386/sgx-epc.h" #endif =20 #include "disas/capstone.h" @@ -5334,6 +5335,25 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, *ecx |=3D CPUID_7_0_ECX_OSPKE; } *edx =3D env->features[FEAT_7_0_EDX]; /* Feature flags */ + + /* + * SGX cannot be emulated in software. If hardware does not + * support enabling SGX and/or SGX flexible launch control, + * then we need to update the VM's CPUID values accordingly. + */ + if ((*ebx & CPUID_7_0_EBX_SGX) && + (!kvm_enabled() || + !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_E= BX) & + CPUID_7_0_EBX_SGX))) { + *ebx &=3D ~CPUID_7_0_EBX_SGX; + } + + if ((*ecx & CPUID_7_0_ECX_SGX_LC) && + (!(*ebx & CPUID_7_0_EBX_SGX) || !kvm_enabled() || + !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_E= CX) & + CPUID_7_0_ECX_SGX_LC))) { + *ecx &=3D ~CPUID_7_0_ECX_SGX_LC; + } } else if (count =3D=3D 1) { *eax =3D env->features[FEAT_7_1_EAX]; *ebx =3D 0; @@ -5469,6 +5489,63 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, } break; } + case 0x12: +#ifndef CONFIG_USER_ONLY + if (!kvm_enabled() || + !(env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_SGX)) { + *eax =3D *ebx =3D *ecx =3D *edx =3D 0; + break; + } + + /* + * SGX sub-leafs CPUID.0x12.{0x2..N} enumerate EPC sections. Retr= ieve + * the EPC properties, e.g. confidentiality and integrity, from the + * host's first EPC section, i.e. assume there is one EPC section = or + * that all EPC sections have the same security properties. + */ + if (count > 1) { + uint64_t epc_addr, epc_size; + + if (sgx_epc_get_section(count - 2, &epc_addr, &epc_size)) { + *eax =3D *ebx =3D *ecx =3D *edx =3D 0; + break; + } + host_cpuid(index, 2, eax, ebx, ecx, edx); + *eax =3D (uint32_t)(epc_addr & 0xfffff000) | 0x1; + *ebx =3D (uint32_t)(epc_addr >> 32); + *ecx =3D (uint32_t)(epc_size & 0xfffff000) | (*ecx & 0xf); + *edx =3D (uint32_t)(epc_size >> 32); + break; + } + + /* + * SGX sub-leafs CPUID.0x12.{0x0,0x1} are heavily dependent on har= dware + * and KVM, i.e. QEMU cannot emulate features to override what KVM + * supports. Features can be further restricted by userspace, but= not + * made more permissive. + */ + *eax =3D kvm_arch_get_supported_cpuid(cs->kvm_state, 0x12, count, = R_EAX); + *ebx =3D kvm_arch_get_supported_cpuid(cs->kvm_state, 0x12, count, = R_EBX); + *ecx =3D kvm_arch_get_supported_cpuid(cs->kvm_state, 0x12, count, = R_ECX); + *edx =3D kvm_arch_get_supported_cpuid(cs->kvm_state, 0x12, count, = R_EDX); + + if (count =3D=3D 0) { + *eax &=3D env->features[FEAT_SGX_12_0_EAX]; + *ebx &=3D env->features[FEAT_SGX_12_0_EBX]; + } else { + *eax &=3D env->features[FEAT_SGX_12_1_EAX]; + *ebx &=3D 0; /* ebx reserve */ + *ecx &=3D env->features[FEAT_XSAVE_COMP_LO]; + *edx &=3D env->features[FEAT_XSAVE_COMP_HI]; + + /* FP and SSE are always allowed regardless of XSAVE/XCR0. */ + *ecx |=3D XSTATE_FP_MASK | XSTATE_SSE_MASK; + + /* Access to PROVISIONKEY requires additional credentials. */ + *eax &=3D ~(1U << 4); + } +#endif + break; case 0x14: { /* Intel Processor Trace Enumeration */ *eax =3D 0; --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834291049458.3500038363726; Tue, 28 Sep 2021 06:04:51 -0700 (PDT) Received: from localhost ([::1]:57664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCmv-0005n8-RR for importer@patchew.org; Tue, 28 Sep 2021 09:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCa7-0006Pu-7J for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:38414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0001Ps-Mw for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:34 -0400 Received: by mail-ed1-x532.google.com with SMTP id dj4so83098347edb.5 for ; Tue, 28 Sep 2021 05:51:32 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n7EpH1eUHbgsU4y2oVIOfkcySimCn2YNElmxUA1pPr0=; b=ePWPUBVPKlTSyyZWU9Dqg/pxes17ywINpwQRYs4wc1R+Gy8A71DJc0ndOp6II5pEXq nqbeJ5HloUZuZkQdLZsHcX9IeZbtQ6hh8F5F8MZcr2Wkpf/mqz74M8MwkP9otXKfXJ+S /IT7+xM7y6IQ4LfW5llrzd5XMyeFgfp84+lGtX0ZhDxh7xwrQXfVsHejremGyuzotzCl HGiDhE+JO4YX9BBrCcGYUS16CevrhNCPQYUBrFm1WTnJKzke1UrhrQ7xMawedt6uef70 hD0vQKXOw2krjGDSBVDLVkahzNjD9rlhXEzHEZ4R7GFqRfR8fI9WWp9oWCR0yyEBkXf3 UL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=n7EpH1eUHbgsU4y2oVIOfkcySimCn2YNElmxUA1pPr0=; b=6Dria1otyMuM7+jXJ5KSC6q5cmZCXDjd4J0NAZqlTQ+RryeduB+btvzNR5wgS2rYPU eyes3SYjjnIr5KS5iGUgn0pz3FvqVlE3F3jS7I9pikX3/AunU9aSBK5Idf8Mq6orr1O3 YJ1p26pxF+zwBfsWq5l9/VBfKp2oA+NnjubACy87vZicq0Sm8anjCYlDlGPY8vLdasqM GNjSwveCtebTWHwvkp1ToKspLXUjvfTC1oTIEIlzX7GmrlmwTPLgfR43tmTkkuvDbtFN yqiJCcXo9BEheH++22pRk7wWtPBCg7kSk6XhgYdQhooiNJJZhX9WgbA45AUAoICpwfso cNGQ== X-Gm-Message-State: AOAM5313C3UpWqgfnmMaoCoesEqemTtXqen6atGmClNTEjO58z4rPYqt ogeyqKxb2ztAqpAJDF/6botXpIFx9PI= X-Google-Smtp-Source: ABdhPJziyUUEJHnvbbxJZQzDePSfmviAoe6FPX7CuEUgIXeiKhbmMUEthi2a3h5AqqD76eTKtB0l/Q== X-Received: by 2002:a17:906:d9ca:: with SMTP id qk10mr355307ejb.220.1632833489675; Tue, 28 Sep 2021 05:51:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 14/33] i386: kvm: Add support for exposing PROVISIONKEY to guest Date: Tue, 28 Sep 2021 14:50:57 +0200 Message-Id: <20210928125116.183620-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834294435100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson If the guest want to fully use SGX, the guest needs to be able to access provisioning key. Add a new KVM_CAP_SGX_ATTRIBUTE to KVM to support provisioning key to KVM guests. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-14-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 5 ++++- target/i386/kvm/kvm.c | 29 +++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8a62986819..de58599a3d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5542,7 +5542,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, *ecx |=3D XSTATE_FP_MASK | XSTATE_SSE_MASK; =20 /* Access to PROVISIONKEY requires additional credentials. */ - *eax &=3D ~(1U << 4); + if ((*eax & (1U << 4)) && + !kvm_enable_sgx_provisioning(cs->kvm_state)) { + *eax &=3D ~(1U << 4); + } } #endif break; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6dc40161e0..488926a95f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -4644,6 +4644,35 @@ void kvm_arch_update_guest_debug(CPUState *cpu, stru= ct kvm_guest_debug *dbg) } } =20 +static bool has_sgx_provisioning; + +static bool __kvm_enable_sgx_provisioning(KVMState *s) +{ + int fd, ret; + + if (!kvm_vm_check_extension(s, KVM_CAP_SGX_ATTRIBUTE)) { + return false; + } + + fd =3D qemu_open_old("/dev/sgx_provision", O_RDONLY); + if (fd < 0) { + return false; + } + + ret =3D kvm_vm_enable_cap(s, KVM_CAP_SGX_ATTRIBUTE, 0, fd); + if (ret) { + error_report("Could not enable SGX PROVISIONKEY: %s", strerror(-re= t)); + exit(1); + } + close(fd); + return true; +} + +bool kvm_enable_sgx_provisioning(KVMState *s) +{ + return MEMORIZE(__kvm_enable_sgx_provisioning(s), has_sgx_provisioning= ); +} + static bool host_supports_vmx(void) { uint32_t ecx, unused; diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 54667b35f0..a978509d50 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -51,4 +51,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp= ); =20 uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address); =20 +bool kvm_enable_sgx_provisioning(KVMState *s); + #endif --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834734434393.4049693134655; Tue, 28 Sep 2021 06:12:14 -0700 (PDT) Received: from localhost ([::1]:45542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCu5-0008PS-Aq for importer@patchew.org; Tue, 28 Sep 2021 09:12:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0006UR-3y for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:40 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:46011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa5-0001Ou-NF for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: by mail-ed1-x52a.google.com with SMTP id r18so6720039edv.12 for ; Tue, 28 Sep 2021 05:51:31 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KOb4IPvQ1urvg2WoCHadP1b4B/KHW5IQqVRTE+ZK8/Y=; b=XJ7upuD06DqDbxRsEHMKxD4xSui8SE9q3I6ZZBE2nnoLQofkkBh0hGxW3A9AlrNjMh m0w7Kjy50B9z8m/H2TX1Mi//qJf9PP+S2Igc3r50b1Tth50PZVVvmTmql5k69H9O57s+ WAQJfxySVFt6PxrrXgvznw5bNozHuEBtTbtMHYc1jwzjVW1ZgXEzIbA19mKqIGFiy/dB c+FcW8lhZFJ0wR26qAL9sye+X3PcWB4G/qo13FM9FmpA4rdtGtxlqqzyHPb9jlyMACcL 0NEOFezXD8cUQfBYmTtDr/f2AeYxo/VXo0yyqWm5iVPqklg2iCcHPqYdvK7+0LnvTqxL ujCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KOb4IPvQ1urvg2WoCHadP1b4B/KHW5IQqVRTE+ZK8/Y=; b=1JbVbVNv40Mfwaa2wn99TQEDt/7DznrcDnpkL+DfwBYJeYMCvsPkGYWgFPiME4iEbx hWUVn2wAANz2oyosJ1CIGQj7qOtIt1k8v/BrBoJMBAAGjfuBa04ceerL6zp0ripchf3P bJmaer9dFgEe3YgvDwXpZGonZHVmi6QJVQ9ODOiHiS4tNGtiBxPSqxNc1ZS1rmR7qYey xzsUs/H+cvC+ni21fgjhpGvKTai/3eltmG4vYm+qY59zXc4g1ySCJI734DaoE3CLy4QL ic+Kkb/84gf962TP0QLQAKhxPWG5vG6/LGFtcOPKYdLW5F5pmMdlp6kXlCMUzi1WrDBM D6fw== X-Gm-Message-State: AOAM531x3UTpc5cASGF6LJEeWmIhJk7Jm8LLV5SpK5KjAis/BH1mwSLA 9xIu77kM6NQOXrt0A6uqTG42t3SrWXg= X-Google-Smtp-Source: ABdhPJxemrzIdundNce05+ThIRwRc2jB81DwoGrVzFz0ysiyjPfMNyaIt9DSthoiqZxS00d2pAgaSw== X-Received: by 2002:a17:906:2c46:: with SMTP id f6mr6348364ejh.542.1632833490376; Tue, 28 Sep 2021 05:51:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/33] i386: Propagate SGX CPUID sub-leafs to KVM Date: Tue, 28 Sep 2021 14:50:58 +0200 Message-Id: <20210928125116.183620-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834735093100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson The SGX sub-leafs are enumerated at CPUID 0x12. Indices 0 and 1 are always present when SGX is supported, and enumerate SGX features and capabilities. Indices >=3D2 are directly correlated with the platform's EPC sections. Because the number of EPC sections is dynamic and user defined, the number of SGX sub-leafs is "NULL" terminated. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-15-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 488926a95f..f6bbf33bc1 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1703,6 +1703,25 @@ int kvm_arch_init_vcpu(CPUState *cs) } break; case 0x7: + case 0x12: + for (j =3D 0; ; j++) { + c->function =3D i; + c->flags =3D KVM_CPUID_FLAG_SIGNIFCANT_INDEX; + c->index =3D j; + cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->ed= x); + + if (j > 1 && (c->eax & 0xf) !=3D 1) { + break; + } + + if (cpuid_i =3D=3D KVM_MAX_CPUID_ENTRIES) { + fprintf(stderr, "cpuid_data is full, no space for " + "cpuid(eax:0x12,ecx:0x%x)\n", j); + abort(); + } + c =3D &cpuid_data.entries[cpuid_i++]; + } + break; case 0x14: { uint32_t times; =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835469633996.3772736281553; Tue, 28 Sep 2021 06:24:29 -0700 (PDT) Received: from localhost ([::1]:44170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD5w-0001W9-Ix for importer@patchew.org; Tue, 28 Sep 2021 09:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0006Yc-QX for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:44 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:44877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaB-0001TJ-TP for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:42 -0400 Received: by mail-ed1-x52b.google.com with SMTP id v18so47486825edc.11 for ; Tue, 28 Sep 2021 05:51:39 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VDdHQ7wAYQQjw1FA0X2CemkmylszfW2NxiKOBkxwC/s=; b=G2hxwVaYmYTouEficz6IpWTbFODxX2ZeUBLtBZ0OAu5MLHNyKO5npYt31fjltGlLRF Jcpfor9gfLTjpPqI4123UHRDV9m2nFL5EQb4im2l5x+SqxH4TY/U6Wsn0EZL0JhnIqEg WBXNsEKBlL5PuuLcyNW5vUvpCfEu9bQ0xGDY36i77TZqibYUFAkhgg65WXcqf5kRSCJV 5HvIVCt2CKoe4sYBP2OqSTN1EEXBFu5ljQq/X5IDfDQGwMrO+aMdcAHO+nzliKsbi0xT O8ICwqgjbA3s2B/ocG8+ik4vr6suh29qIwVZKfYhTdQZburyVaAwDN3RBQXza9S0eVFX CqVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VDdHQ7wAYQQjw1FA0X2CemkmylszfW2NxiKOBkxwC/s=; b=oj88hjWLXJ8ccF5fjORnHC5io0TOl1u+Qq3bid2qIXT9DOqGM5kpwtOWiHH0brdQLy mOnv71Iq2tFDBpAyWeL/jgoCRpVHwgoJ7D6QdQwRw6ng+jz0UnI15IjnQ8X1HYocF4FY qGr9e6jKdUGe/CiUyDdLRokTrcx4DbyKki+PjazP84eQR1gvRogJyC4/8ebeYwtn+Xaj tfH0+dmXxzVQXQBQHX9+HaHcbQ+Jxn/rMMdu6w5MDDQjsC7e1jCfEyy6xUMzSGL9R9tU 1PT31vPAHQ0b1oKgjYraLsSpAcQjuYQGFDNaomhn/BLl4ausIDWszmM4r+Vgt4G2iFej bQwg== X-Gm-Message-State: AOAM531fEXLphymUK4oojuIzQxHd+Dz/ije6ZsQTyKkzHMRzjDWUBuWN bqeLXDFBJTc+l/CAvHNC7aRQWCRVK3s= X-Google-Smtp-Source: ABdhPJwBCVM7VTHic1sYvntuT0gdkm/XHf9RsheMsIR/MVmh3pjsMZXhdN8xWM+rUALMcJ1HkINhMA== X-Received: by 2002:a05:6402:1841:: with SMTP id v1mr7377592edy.170.1632833491401; Tue, 28 Sep 2021 05:51:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 16/33] Adjust min CPUID level to 0x12 when SGX is enabled Date: Tue, 28 Sep 2021 14:50:59 +0200 Message-Id: <20210928125116.183620-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835470911100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson SGX capabilities are enumerated through CPUID_0x12. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-16-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index de58599a3d..cacec605bf 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6154,6 +6154,11 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) if (sev_enabled()) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F); } + + /* 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); + } } =20 /* Set cpuid_*level* based on cpuid_min_*level, if not explicitly set = */ --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834870952189.54811281817808; Tue, 28 Sep 2021 06:14:30 -0700 (PDT) Received: from localhost ([::1]:51418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCwH-00042F-Ia for importer@patchew.org; Tue, 28 Sep 2021 09:14:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0006Uo-6o for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:40 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:43571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa6-0001Q4-II for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:36 -0400 Received: by mail-ed1-x532.google.com with SMTP id v10so78451380edj.10 for ; Tue, 28 Sep 2021 05:51:34 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6HvVwDW0UEsMND2Epmw+EH1l2m7EcZiok6GeyK4r1PQ=; b=qRhNf5AkSiMLm3G+eCy2k5t8N9duo3ALrxMhGLyWhlawhd/iIe42WxWezWkSjQD3xK pmXyz7wBNa7m925hiSHMzCHmYnDgKKTNAUpfn3UX3FSLzdawyEoqGslV1LrQ69fU3kq7 k9tCoT5GRfty2ai7gEMAW/NmKxIYmSsSfl3ZPpSVovVpzY0/f1RtQKGjijv5uz0W8iAu mF77ol53UIiKb2ikynvrwe2ZLLPvB9ETdpPbSsNdFms+qFwXTDR9GcnZMB+9JUXbl/zo iGTGjT+TZ3UJlVXCDV06Ci2qGFu4odZ0xmHcRe3MNNyDvYCKt1JrPixyArzAYZMfQZLp k0Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=6HvVwDW0UEsMND2Epmw+EH1l2m7EcZiok6GeyK4r1PQ=; b=MrCOEFiP64anbspHc2WGM9z4IXHcds1ZqqmL11zgN9pdxY2OEpckQ4tMMv+jqZ+8hN A1O6foH0MtSV2V7JnwMVc2ubBtgKMTHSCKAZlbjZ1Bafim/wUowJ+seyN9n1RdQjSNUB 3VCEKjSly5k8eyG5Vc+3tGh+asmrnvXxJNtJZxGOqsooKHpfZNOPPiCA3yNmhf7x03i0 I8hqt0YXCFXdzXoXxbwHNWNpZDyAAllLcgRCl2Xc6YRB72wmtWSCBc9trgbvGYPWUfgl qHfcYhyT/sINnbj/wEDWcxGtQwK+YJhuR6SyudyhmXlnjpvnLX2wMFxondJzlHDrFbcX JcZg== X-Gm-Message-State: AOAM531lB58wF1itIqn4UabMV2C29swrl/gWKZ80g5Xf7SQXus9LRSpA Y0UO0utawOXmg2M1e2XMA5J4PA7yNyc= X-Google-Smtp-Source: ABdhPJzNC9dCKoDE0OP8z4fO2kSGl69ROSlG+0s4zK6CJx60qzG6p+5Y6s/2VMr4DKgJeh5LCrXRkQ== X-Received: by 2002:a17:907:7601:: with SMTP id jx1mr6485896ejc.69.1632833492136; Tue, 28 Sep 2021 05:51:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 17/33] hw/i386/fw_cfg: Set SGX bits in feature control fw_cfg accordingly Date: Tue, 28 Sep 2021 14:51:00 +0200 Message-Id: <20210928125116.183620-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834872572100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Request SGX an SGX Launch Control to be enabled in FEATURE_CONTROL when the features are exposed to the guest. Our design is the SGX Launch Control bit will be unconditionally set in FEATURE_CONTROL, which is unlike host bios. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-17-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/fw_cfg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 4e68d5dea4..f6d036dfbe 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -159,7 +159,7 @@ void fw_cfg_build_feature_control(MachineState *ms, FWC= fgState *fw_cfg) { X86CPU *cpu =3D X86_CPU(ms->possible_cpus->cpus[0].cpu); CPUX86State *env =3D &cpu->env; - uint32_t unused, ecx, edx; + uint32_t unused, ebx, ecx, edx; uint64_t feature_control_bits =3D 0; uint64_t *val; =20 @@ -174,6 +174,14 @@ void fw_cfg_build_feature_control(MachineState *ms, FW= CfgState *fw_cfg) feature_control_bits |=3D FEATURE_CONTROL_LMCE; } =20 + cpu_x86_cpuid(env, 0x7, 0, &unused, &ebx, &ecx, &unused); + if (ebx & CPUID_7_0_EBX_SGX) { + feature_control_bits |=3D FEATURE_CONTROL_SGX; + } + if (ecx & CPUID_7_0_ECX_SGX_LC) { + feature_control_bits |=3D FEATURE_CONTROL_SGX_LC; + } + if (!feature_control_bits) { return; } --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163283476304787.63040428080251; Tue, 28 Sep 2021 06:12:43 -0700 (PDT) Received: from localhost ([::1]:46556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCuX-0000kU-VK for importer@patchew.org; Tue, 28 Sep 2021 09:12:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0006Us-70 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:40 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:43564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCa7-0001R0-Dx for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:37 -0400 Received: by mail-ed1-x52a.google.com with SMTP id v10so78451561edj.10 for ; Tue, 28 Sep 2021 05:51:35 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WkjhuyBO0N6fxaVEUOUbeysGxGrIJEx9LEs65ZvcK4A=; b=hUc4ZAUcXJICdh5F+kwTHaPFOKxi9VBPGoLQsPYXnQF/tg4fHUcSuvnI2umzEw78yx +fhZnLECZQ8qg/vhXGzA7tqC+FuwJCF0gbRbomZHY+st3q7ObkUtHRpqMFIaj+HwpLVE g3sfhIJu7dMKLf+NwziH5eGwgI1mSDLGa2ARbU5QwWPVEiBBh1XITVlWsU3hYKXK+k9Q MX7IZ8z6SRyReeHOHDUg7+tqL0/8C689hiD+5z3azmJvxki/yKcZ9g2eNhh6Go0DmQI7 +gUgWtvVtCZiu5u84cip9mhskpMWLFIxe4JJ+q+rY46ovbLtEV8fWFkezALMbWYoXcQi jpZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=WkjhuyBO0N6fxaVEUOUbeysGxGrIJEx9LEs65ZvcK4A=; b=THFWBuyET3xJlbPQmXQh67FRohg/Erx24MPfqbTBv/CSFBuSMbVJcSblStmlU9mA90 WK57QajOt7rib/imG7YenTGkcP7CJ80jc8ukox1yUdmD31vPBSsCVng1IOcS6mxr4d9C Fe3+bP9P4/FA2YnS947x/JOW/m3psrtGX4cTsRaAW9CG5nZW7CvgKUHac2nzKTL89SD0 CXjEn346Is/G9zDzrrPw1qnP1XlvII4vdnroaalA8EyQE2RuE03RdlhXcFqypAUFHk6L sf03iDOsOmcghXkdLbdMW/km2uYmXprHxg6Mba6aKIk0huWanjTduGGywtAa0xMNRFty /khA== X-Gm-Message-State: AOAM531MyDGa4xxoJeicPH0+H4mTrH8CSJmfev9rKijT2DhzI18zINlc gMwUT6+G7gonS5tWDQ6A99TGywpOxUw= X-Google-Smtp-Source: ABdhPJzEFCyQqkc2Qn7JhqglQAijAkRXlO1scmb+FzINwth9uuJr2draB7ZhfOLOpWGDKp6Uw6lAiA== X-Received: by 2002:a17:906:fa90:: with SMTP id lt16mr6522905ejb.567.1632833492833; Tue, 28 Sep 2021 05:51:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 18/33] hw/i386/pc: Account for SGX EPC sections when calculating device memory Date: Tue, 28 Sep 2021 14:51:01 +0200 Message-Id: <20210928125116.183620-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834763972100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Add helpers to detect if SGX EPC exists above 4g, and if so, where SGX EPC above 4g ends. Use the helpers to adjust the device memory range if SGX EPC exists above 4g. For multiple virtual EPC sections, we just put them together physically contiguous for the simplicity because we don't support EPC NUMA affinity now. Once the SGX EPC NUMA support in the kernel SGX driver, we will support this in the future. Note that SGX EPC is currently hardcoded to reside above 4g. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-18-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 11 ++++++++++- include/hw/i386/sgx-epc.h | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 557d49c9f8..e41c002539 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -919,8 +919,15 @@ void pc_memory_init(PCMachineState *pcms, exit(EXIT_FAILURE); } =20 + if (pcms->sgx_epc.size !=3D 0) { + machine->device_memory->base =3D sgx_epc_above_4g_end(&pcms->s= gx_epc); + } else { + machine->device_memory->base =3D + 0x100000000ULL + x86ms->above_4g_mem_size; + } + machine->device_memory->base =3D - ROUND_UP(0x100000000ULL + x86ms->above_4g_mem_size, 1 * GiB); + ROUND_UP(machine->device_memory->base, 1 * GiB); =20 if (pcmc->enforce_aligned_dimm) { /* size device region assuming 1G page max alignment per slot = */ @@ -1005,6 +1012,8 @@ uint64_t pc_pci_hole64_start(void) if (!pcmc->broken_reserved_end) { hole64_start +=3D memory_region_size(&ms->device_memory->mr); } + } else if (pcms->sgx_epc.size !=3D 0) { + hole64_start =3D sgx_epc_above_4g_end(&pcms->sgx_epc); } else { hole64_start =3D 0x100000000ULL + x86ms->above_4g_mem_size; } diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h index 75b19f464c..65a68ca753 100644 --- a/include/hw/i386/sgx-epc.h +++ b/include/hw/i386/sgx-epc.h @@ -57,4 +57,11 @@ typedef struct SGXEPCState { =20 int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size); =20 +static inline uint64_t sgx_epc_above_4g_end(SGXEPCState *sgx_epc) +{ + assert(sgx_epc !=3D NULL && sgx_epc->base >=3D 0x100000000ULL); + + return sgx_epc->base + sgx_epc->size; +} + #endif --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835679726493.17963697153925; Tue, 28 Sep 2021 06:27:59 -0700 (PDT) Received: from localhost ([::1]:51630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD9K-0006gl-NE for importer@patchew.org; Tue, 28 Sep 2021 09:27:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaN-0006gt-7u for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:35624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaL-0001ZY-N9 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: by mail-ed1-x52f.google.com with SMTP id l8so34475902edw.2 for ; Tue, 28 Sep 2021 05:51:49 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1CNuKWJpiXhOuvCaQUOZDf4tSaDbDrxbru4USDls+5I=; b=BfvvaF2+sZR400nnQ2W/1SmfADsRsW3wNFQnw/4TjPy7n/rw7fJ1xGHIfpImeoncL3 7G+PINRh/d8/QYx1Y74Fq0Ja22qNdyTJjQBxVyI6IBoDx4Zffym99Mf/Mv2+P/0iNKpY FTU2l8Eef7rWEsFz3a1Q2v7mYaXa4x6wVj6eoI7LRVN3H7TIAtdicWKi6U/iUN/9TlY2 HqF4NN2yHs0+UkzYDzzUcWdGKFkxN04ufOXsA2cPO89m3BLSpzBBcEiYMTxlwgPmJ/z1 Vg9rOknW9MIBh8OA2igqQFvQl0Ny2yuDpZ99ABYBUafg4tCAskrrXsUVVrcto3PIIDL3 TZbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1CNuKWJpiXhOuvCaQUOZDf4tSaDbDrxbru4USDls+5I=; b=IxYA/ju/PkXxGty0g3esk6hSe/SzGG7cUjS2iXLqBMWKNexi5NoBN+6aHi44fsRbvq dYJa9qM0zsVRWTUospAW1JHGQzi5MHkbtF5xYsuthFp2Ekm5wuioz6SjWzAb8+x+U9tA 4SF/lfvpKzz34QjQ7SdquZhhW39hqACpzX+qCABirqNCDKKAapzvgwW423prfJ75rW5Y YDl7kTBs5Hm31fcKaKOfNrb7E8jMJytrNOCTRk5mFf+L/NhjdQebg2TDURzHbWQiLT8r adrscFim9t1wVcyMgOJXmxJfpmqp58qwikvhSf7+pMf1YrwUONfaXOworbLriaiWDCZy LgvA== X-Gm-Message-State: AOAM533Z4APsnvJ6DUmkwJ5sBeiv1DbTi5fb4Pzy4yJ6pNsd7wxSLWDI L39++KjED3o1crGXx/hEeTL3R4JD3BM= X-Google-Smtp-Source: ABdhPJzCI5ZAOpCUjY3r5j5zGvlror1pwfHqFvcCl7ge2xjGfDD7DP2yAmhF+8LNDz1lIDVoiGiZXQ== X-Received: by 2002:a05:6402:16d8:: with SMTP id r24mr764649edx.47.1632833493980; Tue, 28 Sep 2021 05:51:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 19/33] i386/pc: Add e820 entry for SGX EPC section(s) Date: Tue, 28 Sep 2021 14:51:02 +0200 Message-Id: <20210928125116.183620-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835681338100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Note that SGX EPC is currently guaranteed to reside in a single contiguous chunk of memory regardless of the number of EPC sections. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-19-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e41c002539..df457eceba 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -889,6 +889,10 @@ void pc_memory_init(PCMachineState *pcms, e820_add_entry(0x100000000ULL, x86ms->above_4g_mem_size, E820_RAM); } =20 + if (pcms->sgx_epc.size !=3D 0) { + e820_add_entry(pcms->sgx_epc.base, pcms->sgx_epc.size, E820_RESERV= ED); + } + if (!pcmc->has_reserved_memory && (machine->ram_slots || (machine->maxram_size > machine->ram_size))) { --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834242876741.4541932795408; Tue, 28 Sep 2021 06:04:02 -0700 (PDT) Received: from localhost ([::1]:54872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCm9-0003sC-Eh for importer@patchew.org; Tue, 28 Sep 2021 09:04:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0006Yf-PU for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:44 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:43575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaB-0001Ru-No for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:41 -0400 Received: by mail-ed1-x535.google.com with SMTP id v10so78451976edj.10 for ; Tue, 28 Sep 2021 05:51:36 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DX+n3kP2aHkHKaZjc+ogt7pnXtaudF677+IzkUFKWcc=; b=FZpabySlet68K3J11vL+SlnpqrcVvVuq9DdVMVraNjiLit6zVhJ0lXrVax5Re/fFe6 5mURSBJWYiSMk8VB+CZZaL+Rc+JNLk+L6iew3hm8hP8BeaFyXN9CjiRz8ENLfcDGWRIH G3x6PwbcGaw1WRc3qjUswuW4ywsyjjr1gGRfWHyipZPvTldKWviTA3l1yqKQ1Aqxspgx Rp2AhXl+ZcdgaQOPBeL194EYHLbWvkJlRP29Ylf7isQfaWL/Ghztzi7AehwXg7Z4TfNY hckRy+6Ir/MyunPq2qa/RvFrKCXIjBAbT5K40+mYderlrP5HOx35cApNqngZRhwwMr56 g4GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DX+n3kP2aHkHKaZjc+ogt7pnXtaudF677+IzkUFKWcc=; b=MbvsdnIgm9hC7DDNKuJYzw9QgPFE9qKSkyb2RuxAzrwQbIeiifZSVojkdszWj5j9Ew k9Ct8cVNJ7u6mzTWotZDvKImfZbzzJpvfAHClYlXOzFq75Cm9cNqjPAgI9qUNZ/RALMb /2kXqT1oBsCGssM9mkKZ/5Vw86o6+4KHcDep6zbRJTD7J4ig/1+xg8aBya69G31mRQMk hwzNQRd6d/MSUePIKIVqVYmJcLJ4Q17+CBAQzi/mRTn7HttX0emNa1/0Oq3ccC+hYct0 MyKRfIru2qLm6K0eq6CHGXphYd1ijGkes4oSz4ANGhye3uJ3IpgwfR6mXiZinwvJZcNv v6Dw== X-Gm-Message-State: AOAM530WkIP0ztlLGlqDkiS7sU1x2AvgrnMrtwS0XM/aQ4Hxt0mrTKJg DMnHdcvuhT6PWSUPP0Z9DJaG4mnfUb4= X-Google-Smtp-Source: ABdhPJxuGanlG0Yto/MDvveAcJpwr6gpadf20J8HmQr8YQ4vRw3ofvKhkRVBh8xbSgwPNo5jgJwzMA== X-Received: by 2002:a05:6402:21d2:: with SMTP id bi18mr7183805edb.21.1632833494784; Tue, 28 Sep 2021 05:51:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 20/33] i386: acpi: Add SGX EPC entry to ACPI tables Date: Tue, 28 Sep 2021 14:51:03 +0200 Message-Id: <20210928125116.183620-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834255113100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson The ACPI Device entry for SGX EPC is essentially a hack whose primary purpose is to provide software with a way to autoprobe SGX support, e.g. to allow software to implement SGX support as a driver. Details on the individual EPC sections are not enumerated through ACPI tables, i.e. software must enumerate the EPC sections via CPUID. Furthermore, software expects to see only a single EPC Device in the ACPI tables regardless of the number of EPC sections in the system. However, several versions of Windows do rely on the ACPI tables to enumerate the address and size of the EPC. So, regardless of the number of EPC sections exposed to the guest, create exactly *one* EPC device with a _CRS entry that spans the entirety of all EPC sections (which are guaranteed to be contiguous in Qemu). Note, NUMA support for EPC memory is intentionally not considered as enumerating EPC NUMA information is not yet defined for bare metal. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-20-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/acpi-build.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index dfaa47cdc2..f4d6ae3d02 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1841,6 +1841,28 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } #endif =20 + if (pcms->sgx_epc.size !=3D 0) { + uint64_t epc_base =3D pcms->sgx_epc.base; + uint64_t epc_size =3D pcms->sgx_epc.size; + + dev =3D aml_device("EPC"); + aml_append(dev, aml_name_decl("_HID", aml_eisaid("INT0E0C"))); + aml_append(dev, aml_name_decl("_STR", + aml_unicode("Enclave Page Cache 1.0"= ))); + crs =3D aml_resource_template(); + aml_append(crs, + aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, + AML_MAX_FIXED, AML_NON_CACHEABLE, + AML_READ_WRITE, 0, epc_base, + epc_base + epc_size - 1, 0, epc_size)); + aml_append(dev, aml_name_decl("_CRS", crs)); + + method =3D aml_method("_STA", 0, AML_NOTSERIALIZED); + aml_append(method, aml_return(aml_int(0x0f))); + aml_append(dev, method); + + aml_append(sb_scope, dev); + } aml_append(dsdt, sb_scope); =20 /* copy AML table into ACPI tables blob and patch header there */ --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835168722831.3526444968554; Tue, 28 Sep 2021 06:19:28 -0700 (PDT) Received: from localhost ([::1]:34524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD15-0003LF-Jf for importer@patchew.org; Tue, 28 Sep 2021 09:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0006Yd-SO for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:44 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:42637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaC-0001TL-7d for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:43 -0400 Received: by mail-ed1-x530.google.com with SMTP id bd28so21418108edb.9 for ; Tue, 28 Sep 2021 05:51:39 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e3CR8xrdtQNpyFMwEEkkK45w7yuIntrOePJfuLXKl2k=; b=MvUvjX/UOKt25ZDPXnUhUu2wGVNRDf9Ak4wQgVWHVZbIQtPrpWl11k55vdZkuX0Th0 kpdX120Yvo2xUZoOuN+oqD40/SZrd48qC8kdabSvUTYdUEuuIk8d8eNNqfQcbND/YLg9 gjFWP38HJCisTgrIoAojzP4hVsOeKTC9bHXFA8DA3QCuK2DTmhT/8LT0K8tDDdqTuWNA aPaz5Tf3Ih6sDRcuyHdnjmNy6n44ScDZZYYrjtTkQu7VSOzU4ieAX0d2C/IPAsNQgUoG 5LiZJVpTYsNO4l7o6M1URiV9kj8Ht8FxRWjLllVNo/1avtVA3hAIVPu2DiWwjXLQASMS MkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=e3CR8xrdtQNpyFMwEEkkK45w7yuIntrOePJfuLXKl2k=; b=14NqpGczIzrgmpeNOQo5Qc1IO6hXdNSy18W46zaguaoUB7FQF0d65ZrUtKXJl5CVqM PO9SdTIBciNU1gkPC6sbhQ4u21cZ/iaBy0mFUbyawxepr+TtG9kicVVIo4OlkuOEcv1k 3LLVDLhcTz+seqp4qTjAWNxioyzS89KpiHJGoHw+vwGuvBnhQGfeoL1L43KkiA4/Xh9j BHaEi3qBX5FQTz4pf8qVe9+zOdZ00MSYVT4qspB90XPu1aX3cYtxPszdGonTVrlZMXit F6aw9AAUexE/e5tw//K+p3hPTyo428SDqB+heW8xtEgpiPmGsKfnp81LSiq4/Qaxfv54 Di1g== X-Gm-Message-State: AOAM533sLF5/8WQHDrCmJ40yIvtkYwnKqq4xjePeL8hSnUg8wTAKhhAD kFXsJmjPUYrcxBvjpgggTDxAhJlzpEU= X-Google-Smtp-Source: ABdhPJwN95IcDGgE1yk4F1SXea+3jNYH2UXmd1Haa75I+ZfHKVPdj5IWmX7zqepM2YeZUqjFxe0LFg== X-Received: by 2002:a17:906:1405:: with SMTP id p5mr6308386ejc.197.1632833495430; Tue, 28 Sep 2021 05:51:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 21/33] q35: Add support for SGX EPC Date: Tue, 28 Sep 2021 14:51:04 +0200 Message-Id: <20210928125116.183620-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835169973100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Enable SGX EPC virtualization, which is currently only support by KVM. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-21-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc_q35.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 46cd542d17..5481d5c965 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -177,6 +177,7 @@ static void pc_q35_init(MachineState *machine) x86ms->below_4g_mem_size =3D machine->ram_size; } =20 + pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); =20 kvmclock_create(pcmc->kvmclock_create_always); --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835693458701.4193741850411; Tue, 28 Sep 2021 06:28:13 -0700 (PDT) Received: from localhost ([::1]:52694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD9Y-0007O6-B5 for importer@patchew.org; Tue, 28 Sep 2021 09:28:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0006Ya-QA for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:44 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:41957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaB-0001Se-PR for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:42 -0400 Received: by mail-ed1-x52c.google.com with SMTP id s17so64109691edd.8 for ; Tue, 28 Sep 2021 05:51:38 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HIpbBVsq+qGYM7QnpoxAN/h8ed4NbHFTGJsvkWBRASU=; b=lYD3sLKIhzvpMGiTXcUKXT6GdlYtwKGK/QRBqu94a4sZ0qGayy7m/EbVrc59y/Ooik HYQ/+tAU4MhVE09RZ1oJtSvr+Vt/wqIEaixLE3qBsVkTaEWsD7EEYSc/HzmHpewq9R7o HVpESZXws85qEObz79eIt4C1Zmn2hWsmKNu711Ka5r+VbtzhqIMlRnaOjYpqcr6JrMMC 0gnVqUuIbfRCjzLkGztJ1jquwzzqHutAtap4nGAsS/DPpmkvq9jYV6ek+wv+orkekE5A f4ut5bo19f9SvpmCopuLV93iMMkK2I4LV6BNK5p9DlVanx0MLYL36MqXSG06nUKGGu2O +XSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HIpbBVsq+qGYM7QnpoxAN/h8ed4NbHFTGJsvkWBRASU=; b=i17xinKJvZ9w9HeIccy8mtScBdPDuZJQ7tcvQsOFC7HZkQjp4m/i4Cko783zZXGsTg aeWqWQ3nt6xE7pvfr8udMnSKkTQGqB7ahDRrOfIZnXwmRIcjAEseOaWgfjidHU+3xsK8 nFtYH7SvL8sSBG7gReRYMiVn/24lZ7hO8qhnYsUVgXDNdDTU5WK6ZZ1mXq03MW1vvXR+ hhGQVDMGHqmg8vY12iQzSU2K+Yt9S6BXn7vmg7uc5Vm9f+/ACMxNXz/M64JcMn/Qf9A8 qjIDFKLoygbvbqSSYLB2gbf5p4i6hfTesB57oHETTRC1SpFsxVzClvVlIfIXHqyHmFQU jdLg== X-Gm-Message-State: AOAM5303X2VTa37T3LP9pC8ihAXOp2ZTwrCXqaUNB6PtP1HVmATQHADZ 055n/Jpti34zZuJzVBCaBg80fYKidqs= X-Google-Smtp-Source: ABdhPJx46ySwMifQ7F9B6giPw51XotA23WITMLWGDmzSR+qp5suB64Av1ul2QU9zQJvrntof6Lp2lw== X-Received: by 2002:aa7:c305:: with SMTP id l5mr7377224edq.205.1632833496328; Tue, 28 Sep 2021 05:51:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 22/33] i440fx: Add support for SGX EPC Date: Tue, 28 Sep 2021 14:51:05 +0200 Message-Id: <20210928125116.183620-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835694894100001 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Enable SGX EPC virtualization, which is currently only support by KVM. Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-22-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc_piix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c5da7739ce..6cc834aff6 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -153,6 +153,7 @@ static void pc_init1(MachineState *machine, } } =20 + pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); =20 if (pcmc->kvmclock_enabled) { --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163283445559359.12468283862984; Tue, 28 Sep 2021 06:07:35 -0700 (PDT) Received: from localhost ([::1]:35266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCpa-0001Eo-IL for importer@patchew.org; Tue, 28 Sep 2021 09:07:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaI-0006eU-7O for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:34472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0001Vt-Ep for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:45 -0400 Received: by mail-ed1-x536.google.com with SMTP id g7so23334099edv.1 for ; Tue, 28 Sep 2021 05:51:43 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=50+7DLLvMJpLvY9tsDPgl4TU2uB7R8yc3w14Pg81CxY=; b=PZYJruypVpVZdUGjp/fn/9x42kajT9xf9+TlI+dnI3WX1sVKetHXn5OQbqLwNjtz++ iypr+i4QT5Z9LbYVO0KVQ6afPosvRRhErg5xXrhyklCTYT61MDmAkGrCFEQkpkKiJVnp WZ+8tkmYYE//Z0R5JS9R1e6G65c23XOC7fp7CARp/RopFe22fvN2d7iYVlmX3uEoVjra zdQsRLvm+/r50Hqec8KO9X2JtqD9YwnRmPjyV86afPOSZNWuRvrPXTK5NxprujojTskr ZCPCOT5eZfF7jP50PbAHpdoyIPkUaWypNI0RZgptjWOtd/5mK/ThIq7Pd0r6VlRM2ld1 TUeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=50+7DLLvMJpLvY9tsDPgl4TU2uB7R8yc3w14Pg81CxY=; b=kidbNJMoCGsJA2L+EMA1T3vVCbfzBwrInY0Zinp9WvHq/DCLAXQXqRq0iPziaVKLay FDTUfabcZVZ6NukElaVocwhXeLCUdHfl6IlmNWhHVFsgaKkqfWqbrEnbeszvTN43i1ir Fwcg2IM2W1aYlfMGkmdvDmx6gfw7sKaBNnvvK1nKCcMjOhirEPeuA1qscvy+Suut8bvr p0BlTBidxSI4dgBBTH8CSfavqs0YUyWbcXigL5TyNCRtS9VFXJ5eRS1nohOECaxYhwdw H4Nodl8CSS2ZwvvPDNkFkFefIQPUvIB3LThuKEPk79nImRyQPm17mLaoyB3eFoihjDzL SHkg== X-Gm-Message-State: AOAM530jWkcA8T63WMioI+BCxJgD/VvrY2Tjv2KgINtHL1d453BbNhdB njjr0X3oQcSVDYlLWuxwoJFBioR/6nw= X-Google-Smtp-Source: ABdhPJx7fezH9l2n1b8/uoSQt/K3DUR6A7ne56ebjJsujE6LZoaih8gpiF6NTM4gI4EeCr17Gy/Ruw== X-Received: by 2002:a05:6402:694:: with SMTP id f20mr7432734edy.100.1632833497024; Tue, 28 Sep 2021 05:51:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 23/33] sgx-epc: Add the fill_device_info() callback support Date: Tue, 28 Sep 2021 14:51:06 +0200 Message-Id: <20210928125116.183620-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834456173100001 Content-Type: text/plain; charset="utf-8" From: Yang Zhong Since there is no fill_device_info() callback support, and when we execute "info memory-devices" command in the monitor, the segfault will be found. This patch will add this callback support and "info memory-devices" will show sgx epc memory exposed to guest. The result as below: qemu) info memory-devices Memory device [sgx-epc]: "" memaddr: 0x180000000 size: 29360128 memdev: /objects/mem1 Memory device [sgx-epc]: "" memaddr: 0x181c00000 size: 10485760 memdev: /objects/mem2 Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-33-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/sgx-epc.c | 11 ++++++++++- monitor/hmp-cmds.c | 10 ++++++++++ qapi/machine.json | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/hw/i386/sgx-epc.c b/hw/i386/sgx-epc.c index 6677dc74b5..55e2217eae 100644 --- a/hw/i386/sgx-epc.c +++ b/hw/i386/sgx-epc.c @@ -133,7 +133,16 @@ static MemoryRegion *sgx_epc_md_get_memory_region(Memo= ryDeviceState *md, static void sgx_epc_md_fill_device_info(const MemoryDeviceState *md, MemoryDeviceInfo *info) { - /* TODO */ + SgxEPCDeviceInfo *se =3D g_new0(SgxEPCDeviceInfo, 1); + SGXEPCDevice *epc =3D SGX_EPC(md); + + se->memaddr =3D epc->addr; + se->size =3D object_property_get_uint(OBJECT(epc), SGX_EPC_SIZE_PROP, + NULL); + se->memdev =3D object_get_canonical_path(OBJECT(epc->hostmem)); + + info->u.sgx_epc.data =3D se; + info->type =3D MEMORY_DEVICE_INFO_KIND_SGX_EPC; } =20 static void sgx_epc_class_init(ObjectClass *oc, void *data) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index b5e71d9e6f..bcaa41350e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1823,6 +1823,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDic= t *qdict) VirtioMEMDeviceInfo *vmi; MemoryDeviceInfo *value; PCDIMMDeviceInfo *di; + SgxEPCDeviceInfo *se; =20 for (info =3D info_list; info; info =3D info->next) { value =3D info->value; @@ -1870,6 +1871,15 @@ void hmp_info_memory_devices(Monitor *mon, const QDi= ct *qdict) vmi->block_size); monitor_printf(mon, " memdev: %s\n", vmi->memdev); break; + case MEMORY_DEVICE_INFO_KIND_SGX_EPC: + se =3D value->u.sgx_epc.data; + monitor_printf(mon, "Memory device [%s]: \"%s\"\n", + MemoryDeviceInfoKind_str(value->type), + se->id ? se->id : ""); + monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", se->mema= ddr); + monitor_printf(mon, " size: %" PRIu64 "\n", se->size); + monitor_printf(mon, " memdev: %s\n", se->memdev); + break; default: g_assert_not_reached(); } diff --git a/qapi/machine.json b/qapi/machine.json index 26c539fe2c..e2f01e9c15 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1194,13 +1194,36 @@ } } =20 +## +# @SgxEPCDeviceInfo: +# +# Sgx EPC state information +# +# @id: device's ID +# +# @memaddr: physical address in memory, where device is mapped +# +# @size: size of memory that the device provides +# +# @memdev: memory backend linked with device +# +# Since: 6.2 +## +{ 'struct': 'SgxEPCDeviceInfo', + 'data': { '*id': 'str', + 'memaddr': 'size', + 'size': 'size', + 'memdev': 'str' + } +} + ## # @MemoryDeviceInfoKind: # # Since: 2.1 ## { 'enum': 'MemoryDeviceInfoKind', - 'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem' ] } + 'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem', 'sgx-epc' ] } =20 ## # @PCDIMMDeviceInfoWrapper: @@ -1225,13 +1248,22 @@ ## { 'struct': 'VirtioMEMDeviceInfoWrapper', 'data': { 'data': 'VirtioMEMDeviceInfo' } } + +## +# @SgxEPCDeviceInfoWrapper: +# +# Since: 6.2 +## +{ 'struct': 'SgxEPCDeviceInfoWrapper', + 'data': { 'data': 'SgxEPCDeviceInfo' } } + ## # @MemoryDeviceInfo: # # Union containing information about a memory device # # nvdimm is included since 2.12. virtio-pmem is included since 4.1. -# virtio-mem is included since 5.1. +# virtio-mem is included since 5.1. sgx-epc is included since 6.2. # # Since: 2.1 ## @@ -1241,7 +1273,8 @@ 'data': { 'dimm': 'PCDIMMDeviceInfoWrapper', 'nvdimm': 'PCDIMMDeviceInfoWrapper', 'virtio-pmem': 'VirtioPMEMDeviceInfoWrapper', - 'virtio-mem': 'VirtioMEMDeviceInfoWrapper' + 'virtio-mem': 'VirtioMEMDeviceInfoWrapper', + 'sgx-epc': 'SgxEPCDeviceInfoWrapper' } } =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835926573885.2646049259935; Tue, 28 Sep 2021 06:32:06 -0700 (PDT) Received: from localhost ([::1]:33122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVDDJ-0005Bg-1A for importer@patchew.org; Tue, 28 Sep 2021 09:32:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaI-0006g2-MG for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:39690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0001UK-DZ for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: by mail-ed1-x52e.google.com with SMTP id x7so68157547edd.6 for ; Tue, 28 Sep 2021 05:51:41 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n2e71CYdYrgeKoDZGg5aC8FSc4Xw4PN68IZuK98DOS4=; b=XnKkzqTT71KcqxKU1ipG/HHnOw/GS1523MZpwOMe09Dg/HpXRhII+tdTTWx1F9nC7r z/SU8TZODt3PKaRpcJ1P7YCXT9k2qbozein+TDJjxcwp9CbF0jmZu0VkYrZu+Sg1s/k/ K2y2hi+cs9VI9WhlNva3/PabxHU5Jzy5iVKsXau5/5NMwLSIuWAWFNU2EJ1eJPejF1fu I+5sYsxvBAZJKLBPoVjs+Os0dMwv43g2YQwrD5LtZc0IUVZxzStQbCh485mjgMsFWQCM VpwKXrkUf7Z9Jy8ai3etrqo4YKkrbD3ZOyB3FiQN7FUQaPdL6OSbfvZ8bUQZ5zss8LuE cQSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=n2e71CYdYrgeKoDZGg5aC8FSc4Xw4PN68IZuK98DOS4=; b=mcNUQuAtlYFaMhUBAbI7G09mktgXeHbstAZHveG1pskP6ACBq2OuT3IXM9x87fFURZ dWxEmiZR8UyZeaallvyB2svvaDxD2TO7U3YmCkdpZcsSnc4r9b6jnbyEQrGKuZ4Jb6ws oLTeekENcbuWCTJezRB6Dp5JJJ0hWbsyc2Fv7AZbqoD+qhLoK5SagqB/aBaQoL8V+QuS yPpTZJAvo9X4k0KChW96G8jS7gqnXwDOd3raI6nRhRABazkSPClyAVlXiQZ6vYcHMfKS OBsH5sjt0cieeg7EV8fcfZmx8D/KYuXojTikzhPSF0hzO5/ycSvZTCpOFSIj2MqLKp0p LTMA== X-Gm-Message-State: AOAM531m9dlFcioYtMB6ik2Q0mW+Inzf6JMglTz4Ys7Jk9g+TTFEOOxf IuarKxYWNWgT/JXM7KGAPHdL7Ccekzc= X-Google-Smtp-Source: ABdhPJyZJFiFdWNIEuq+lrBPD6DonDokrFScAHzvzMEMy4rY3Ouoo2IKn+3z9WCfQUNvB1ixbZCXbQ== X-Received: by 2002:a05:6402:2889:: with SMTP id eg9mr7657614edb.384.1632833497787; Tue, 28 Sep 2021 05:51:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 24/33] docs/system: Add SGX documentation to the system manual Date: Tue, 28 Sep 2021 14:51:07 +0200 Message-Id: <20210928125116.183620-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835927258100005 Content-Type: text/plain; charset="utf-8" From: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Yang Zhong Message-Id: <20210719112136.57018-34-yang.zhong@intel.com> [Convert to reStructuredText, and adopt the standard =3D=3D=3D --- ~~~ head= ings suggested for example by Linux. - Paolo] Signed-off-by: Paolo Bonzini --- docs/system/i386/sgx.rst | 165 ++++++++++++++++++++++++++++++++++++ docs/system/target-i386.rst | 1 + 2 files changed, 166 insertions(+) create mode 100644 docs/system/i386/sgx.rst diff --git a/docs/system/i386/sgx.rst b/docs/system/i386/sgx.rst new file mode 100644 index 0000000000..f103ae2a2f --- /dev/null +++ b/docs/system/i386/sgx.rst @@ -0,0 +1,165 @@ +Software Guard eXtensions (SGX) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + +Overview +-------- + +Intel Software Guard eXtensions (SGX) is a set of instructions and mechani= sms +for memory accesses in order to provide security accesses for sensitive +applications and data. SGX allows an application to use it's pariticular +address space as an *enclave*, which is a protected area provides confiden= tiality +and integrity even in the presence of privileged malware. Accesses to the +enclave memory area from any software not resident in the enclave are prev= ented, +including those from privileged software. + +Virtual SGX +----------- + +SGX feature is exposed to guest via SGX CPUID. Looking at SGX CPUID, we can +report the same CPUID info to guest as on host for most of SGX CPUID. With +reporting the same CPUID guest is able to use full capacity of SGX, and KVM +doesn't need to emulate those info. + +The guest's EPC base and size are determined by Qemu, and KVM needs Qemu to +notify such info to it before it can initialize SGX for guest. + +Virtual EPC +~~~~~~~~~~~ + +By default, Qemu does not assign EPC to a VM, i.e. fully enabling SGX in a= VM +requires explicit allocation of EPC to the VM. Similar to other specialized +memory types, e.g. hugetlbfs, EPC is exposed as a memory backend. + +SGX EPC is enumerated through CPUID, i.e. EPC "devices" need to be realized +prior to realizing the vCPUs themselves, which occurs long before generic +devices are parsed and realized. This limitation means that EPC does not +require -maxmem as EPC is not treated as {cold,hot}plugged memory. + +Qemu does not artificially restrict the number of EPC sections exposed to a +guest, e.g. Qemu will happily allow you to create 64 1M EPC sections. Be a= ware +that some kernels may not recognize all EPC sections, e.g. the Linux SGX d= river +is hardwired to support only 8 EPC sections. + +The following Qemu snippet creates two EPC sections, with 64M pre-allocated +to the VM and an additional 28M mapped but not allocated:: + + -object memory-backend-epc,id=3Dmem1,size=3D64M,prealloc=3Don \ + -object memory-backend-epc,id=3Dmem2,size=3D28M \ + -M sgx-epc.0.memdev=3Dmem1,sgx-epc.1.memdev=3Dmem2 + +Note: + +The size and location of the virtual EPC are far less restricted compared +to physical EPC. Because physical EPC is protected via range registers, +the size of the physical EPC must be a power of two (though software sees +a subset of the full EPC, e.g. 92M or 128M) and the EPC must be naturally +aligned. KVM SGX's virtual EPC is purely a software construct and only +requires the size and location to be page aligned. Qemu enforces the EPC +size is a multiple of 4k and will ensure the base of the EPC is 4k aligned. +To simplify the implementation, EPC is always located above 4g in the guest +physical address space. + +Migration +~~~~~~~~~ + +Qemu/KVM doesn't prevent live migrating SGX VMs, although from hardware's +perspective, SGX doesn't support live migration, since both EPC and the SGX +key hierarchy are bound to the physical platform. However live migration +can be supported in the sense if guest software stack can support recreati= ng +enclaves when it suffers sudden lose of EPC; and if guest enclaves can det= ect +SGX keys being changed, and handle gracefully. For instance, when ERESUME = fails +with #PF.SGX, guest software can gracefully detect it and recreate enclave= s; +and when enclave fails to unseal sensitive information from outside, it can +detect such error and sensitive information can be provisioned to it again. + +CPUID +~~~~~ + +Due to its myriad dependencies, SGX is currently not listed as supported +in any of Qemu's built-in CPU configuration. To expose SGX (and SGX Launch +Control) to a guest, you must either use `-cpu host` to pass-through the +host CPU model, or explicitly enable SGX when using a built-in CPU model, +e.g. via `-cpu ,+sgx` or `-cpu ,+sgx,+sgxlc`. + +All SGX sub-features enumerated through CPUID, e.g. SGX2, MISCSELECT, +ATTRIBUTES, etc... can be restricted via CPUID flags. Be aware that enforc= ing +restriction of MISCSELECT, ATTRIBUTES and XFRM requires intercepting ECREA= TE, +i.e. may marginally reduce SGX performance in the guest. All SGX sub-featu= res +controlled via -cpu are prefixed with "sgx", e.g.:: + + $ qemu-system-x86_64 -cpu help | xargs printf "%s\n" | grep sgx + sgx + sgx-debug + sgx-encls-c + sgx-enclv + sgx-exinfo + sgx-kss + sgx-mode64 + sgx-provisionkey + sgx-tokenkey + sgx1 + sgx2 + sgxlc + +The following Qemu snippet passes through the host CPU but restricts acces= s to +the provision and EINIT token keys:: + + -cpu host,-sgx-provisionkey,-sgx-tokenkey + +SGX sub-features cannot be emulated, i.e. sub-features that are not present +in hardware cannot be forced on via '-cpu'. + +Virtualize SGX Launch Control +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Qemu SGX support for Launch Control (LC) is passive, in the sense that it +does not actively change the LC configuration. Qemu SGX provides the user +the ability to set/clear the CPUID flag (and by extension the associated +IA32_FEATURE_CONTROL MSR bit in fw_cfg) and saves/restores the LE Hash MSRs +when getting/putting guest state, but Qemu does not add new controls to +directly modify the LC configuration. Similar to hardware behavior, locki= ng +the LC configuration to a non-Intel value is left to guest firmware. Unli= ke +host bios setting for SGX launch control(LC), there is no special bios set= ting +for SGX guest by our design. If host is in locked mode, we can still allow +creating VM with SGX. + +Feature Control +~~~~~~~~~~~~~~~ + +Qemu SGX updates the `etc/msr_feature_control` fw_cfg entry to set the SGX +(bit 18) and SGX LC (bit 17) flags based on their respective CPUID support, +i.e. existing guest firmware will automatically set SGX and SGX LC accordi= ngly, +assuming said firmware supports fw_cfg.msr_feature_control. + +Launching a guest +----------------- + +To launch a SGX guest: + +.. parsed-literal:: + + |qemu_system_x86| \\ + -cpu host,+sgx-provisionkey \\ + -object memory-backend-epc,id=3Dmem1,size=3D64M,prealloc=3Don \\ + -object memory-backend-epc,id=3Dmem2,size=3D28M \\ + -M sgx-epc.0.memdev=3Dmem1,sgx-epc.1.memdev=3Dmem2 + +Utilizing SGX in the guest requires a kernel/OS with SGX support. +The support can be determined in guest by:: + + $ grep sgx /proc/cpuinfo + +and SGX epc info by:: + + $ dmesg | grep sgx + [ 1.242142] sgx: EPC section 0x180000000-0x181bfffff + [ 1.242319] sgx: EPC section 0x181c00000-0x1837fffff + +References +---------- + +- `SGX Homepage `__ + +- `SGX SDK `__ + +- SGX specification: Intel SDM Volume 3 diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst index c9720a8cd1..6a86d63863 100644 --- a/docs/system/target-i386.rst +++ b/docs/system/target-i386.rst @@ -26,6 +26,7 @@ Architectural features :maxdepth: 1 =20 i386/cpu + i386/sgx =20 .. _pcsys_005freq: =20 --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835360726361.6603242439056; Tue, 28 Sep 2021 06:22:40 -0700 (PDT) Received: from localhost ([::1]:41248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD4A-0007xU-48 for importer@patchew.org; Tue, 28 Sep 2021 09:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaJ-0006gj-72 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:36731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0001VI-Fx for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: by mail-ed1-x52d.google.com with SMTP id y35so31711282ede.3 for ; Tue, 28 Sep 2021 05:51:42 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7aIHkITyfDCPKw7jzecCNevaMEbatHzwC1yR+VL6gh4=; b=RQgb65pItN8ERUSJnhcK3syXRZjZZ3Hfm//5kfgXsKZyHbuGYsxPx+pzpMTp9zxpMO f54K6aCpgSMR1mPYs3+xjyPeseiutgMoXJAcm9o6XXxDyruaXkQsBkx6Usf6G7Yz2/eL kQTJAfM3Q9/CgE5dR2REi1ZBmUZ97q9G2/b13krvKsqd0ZWRrTAS+d4nRiTO7pv23HpD RYDKqaJCwbwYw9v2Fm6XbuqfoYM2Kbio3tPFf9LfSr7a3R6rULLiSyPgTy9GyQCC6gq/ 0y1C99Qk6n/gBsH4hxbUCA0HFSBLrLxrHAcbw5Ro7EdFLHKMsecbzCXSTer7dg8iDc4y gM3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7aIHkITyfDCPKw7jzecCNevaMEbatHzwC1yR+VL6gh4=; b=dVQPZXthVkWW6hrRP1VkCociZEguYN9yJgahPbzVesvJ9YWs8jPWD/SDrT5LHUfYly NKZl1i38/NUADLxj6LtgK7zH3jXVorwvu79kPxWmX51dyikGvdkc2hfMZK3RDaL/0+1U j9LH5rZEzaJtCGjVRk3Ve7pyebWEYQ8dMsOECf3RDP3TnfOS7ooXcQFMDwemL2K+gSvw v5taHSpXoXDwAFfetzAVGxbi2zsFd94/GGkgi/37mNXz5415jQ2gwXrVSajxBjR/FBPm aoRjCvbU/+JY345h/qiNBI+xXpo+kDAjw1vqMttzYNhCth4CzGWpYMbYp+mz/kEf9hVR yKLw== X-Gm-Message-State: AOAM5335nHW3zG1YWeKUX4dsmL7nyjPwHhYahLD8aeg+uq6LbBHVUY7j c29alm4fkZwPkp62uv4O20203mxL8rs= X-Google-Smtp-Source: ABdhPJwdEP21lGkflRJv7gkvKm7cJYlwpUHL/r9xIjxWv9xvoO6H46k7AE41MNtIlFp7YTnB/jTnoQ== X-Received: by 2002:a17:906:1749:: with SMTP id d9mr6302442eje.178.1632833498515; Tue, 28 Sep 2021 05:51:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 25/33] target/i386: Add HMP and QMP interfaces for SGX Date: Tue, 28 Sep 2021 14:51:08 +0200 Message-Id: <20210928125116.183620-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835362175100001 Content-Type: text/plain; charset="utf-8" From: Yang Zhong The QMP and HMP interfaces can be used by monitor or QMP tools to retrieve the SGX information from VM side when SGX is enabled on Intel platform. Signed-off-by: Yang Zhong Message-Id: <20210910102258.46648-2-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 15 +++++++++++++ hw/i386/sgx-stub.c | 7 ++++++ hw/i386/sgx.c | 31 ++++++++++++++++++++++++++ include/hw/i386/sgx.h | 11 +++++++++ include/monitor/hmp-target.h | 1 + qapi/misc-target.json | 43 ++++++++++++++++++++++++++++++++++++ target/i386/monitor.c | 27 ++++++++++++++++++++++ tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 136 insertions(+) create mode 100644 include/hw/i386/sgx.h diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 27206ac049..4c966e8a6b 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -877,3 +877,18 @@ SRST ``info dirty_rate`` Display the vcpu dirty rate information. ERST + +#if defined(TARGET_I386) + { + .name =3D "sgx", + .args_type =3D "", + .params =3D "", + .help =3D "show intel SGX information", + .cmd =3D hmp_info_sgx, + }, +#endif + +SRST + ``info sgx`` + Show intel SGX information. +ERST diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c index 483c72bba6..485e16ecc1 100644 --- a/hw/i386/sgx-stub.c +++ b/hw/i386/sgx-stub.c @@ -1,6 +1,13 @@ #include "qemu/osdep.h" #include "hw/i386/pc.h" #include "hw/i386/sgx-epc.h" +#include "hw/i386/sgx.h" + +SGXInfo *sgx_get_info(Error **errp) +{ + error_setg(errp, "SGX support is not compiled in"); + return NULL; +} =20 void pc_machine_init_sgx_epc(PCMachineState *pcms) { diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c index 8a18cddc3f..ea75398575 100644 --- a/hw/i386/sgx.c +++ b/hw/i386/sgx.c @@ -17,6 +17,37 @@ #include "monitor/qdev.h" #include "qapi/error.h" #include "exec/address-spaces.h" +#include "hw/i386/sgx.h" + +SGXInfo *sgx_get_info(Error **errp) +{ + SGXInfo *info =3D NULL; + X86MachineState *x86ms; + PCMachineState *pcms =3D + (PCMachineState *)object_dynamic_cast(qdev_get_machine(), + TYPE_PC_MACHINE); + if (!pcms) { + error_setg(errp, "SGX is only supported on PC machines"); + return NULL; + } + + x86ms =3D X86_MACHINE(pcms); + if (!x86ms->sgx_epc_list) { + error_setg(errp, "No EPC regions defined, SGX not available"); + return NULL; + } + + SGXEPCState *sgx_epc =3D &pcms->sgx_epc; + info =3D g_new0(SGXInfo, 1); + + info->sgx =3D true; + info->sgx1 =3D true; + info->sgx2 =3D true; + info->flc =3D true; + info->section_size =3D sgx_epc->size; + + return info; +} =20 int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { diff --git a/include/hw/i386/sgx.h b/include/hw/i386/sgx.h new file mode 100644 index 0000000000..2bf90b3f4f --- /dev/null +++ b/include/hw/i386/sgx.h @@ -0,0 +1,11 @@ +#ifndef QEMU_SGX_H +#define QEMU_SGX_H + +#include "qom/object.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qapi/qapi-types-misc-target.h" + +SGXInfo *sgx_get_info(Error **errp); + +#endif diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h index 60fc92722a..dc53add7ee 100644 --- a/include/monitor/hmp-target.h +++ b/include/monitor/hmp-target.h @@ -49,5 +49,6 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict); void hmp_mce(Monitor *mon, const QDict *qdict); void hmp_info_local_apic(Monitor *mon, const QDict *qdict); void hmp_info_io_apic(Monitor *mon, const QDict *qdict); +void hmp_info_sgx(Monitor *mon, const QDict *qdict); =20 #endif /* MONITOR_HMP_TARGET_H */ diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 3b05ad3dbf..e2a347cc23 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -333,3 +333,46 @@ { 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' }, 'returns': 'SevAttestationReport', 'if': 'TARGET_I386' } + +## +# @SGXInfo: +# +# Information about intel Safe Guard eXtension (SGX) support +# +# @sgx: true if SGX is supported +# +# @sgx1: true if SGX1 is supported +# +# @sgx2: true if SGX2 is supported +# +# @flc: true if FLC is supported +# +# @section-size: The EPC section size for guest +# +# Since: 6.2 +## +{ 'struct': 'SGXInfo', + 'data': { 'sgx': 'bool', + 'sgx1': 'bool', + 'sgx2': 'bool', + 'flc': 'bool', + 'section-size': 'uint64'}, + 'if': 'TARGET_I386' } + +## +# @query-sgx: +# +# Returns information about SGX +# +# Returns: @SGXInfo +# +# Since: 6.2 +# +# Example: +# +# -> { "execute": "query-sgx" } +# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true, +# "flc": true, "section-size" : 0 } } +# +## +{ 'command': 'query-sgx', 'returns': 'SGXInfo', 'if': 'TARGET_I386' } diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 119211f0b0..d7384ba348 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -35,6 +35,7 @@ #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h" #include "hw/i386/pc.h" +#include "hw/i386/sgx.h" =20 /* Perform linear address sign extension */ static hwaddr addr_canonical(CPUArchState *env, hwaddr addr) @@ -763,3 +764,29 @@ qmp_query_sev_attestation_report(const char *mnonce, E= rror **errp) { return sev_get_attestation_report(mnonce, errp); } + +SGXInfo *qmp_query_sgx(Error **errp) +{ + return sgx_get_info(errp); +} + +void hmp_info_sgx(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + g_autoptr(SGXInfo) info =3D qmp_query_sgx(&err); + + if (err) { + error_report_err(err); + return; + } + monitor_printf(mon, "SGX support: %s\n", + info->sgx ? "enabled" : "disabled"); + monitor_printf(mon, "SGX1 support: %s\n", + info->sgx1 ? "enabled" : "disabled"); + monitor_printf(mon, "SGX2 support: %s\n", + info->sgx2 ? "enabled" : "disabled"); + monitor_printf(mon, "FLC support: %s\n", + info->flc ? "enabled" : "disabled"); + monitor_printf(mon, "size: %" PRIu64 "\n", + info->section_size); +} diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index c98b78d033..b75f3364f3 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -100,6 +100,7 @@ static bool query_is_ignored(const char *cmd) /* Success depends on Host or Hypervisor SEV support */ "query-sev", "query-sev-capabilities", + "query-sgx", NULL }; int i; --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632836162367406.04807801812126; Tue, 28 Sep 2021 06:36:02 -0700 (PDT) Received: from localhost ([::1]:41898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVDH7-0002gw-6X for importer@patchew.org; Tue, 28 Sep 2021 09:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaK-0006gn-Iq for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:44889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaI-0001XH-S0 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:48 -0400 Received: by mail-ed1-x535.google.com with SMTP id v18so47488045edc.11 for ; Tue, 28 Sep 2021 05:51:46 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ohYcK/h+3ibYka7ysojEKUGWGgYiFqj771QZXpbZi94=; b=bP5cRoCnTEx13Ay3LjxgwsYhFnHGppmVU059ZlJhidzLWFq+FZ24k6yg1xy+ruABYu iWp1Yy0dDg1+1fOe/lw4yze60bFX4ypEd22pqFrm5h6E9P98E1IRNcT7h24Ukm0lguYS xSzdK5FlvipGj1i00SG0vCU65pHzjghs/BlLoUmWn+xF2+YShlJzWt9kbCFlNK5RIekD 7moKo53z4NIFpMDhhb2Kx86sCUXYHLwBL5z8PQkrK9kikEWewGY6wk8oPYiIaOEj0h1h YyegZ/Oc76iJ84JhmHGiOiAtPxEq8Fok5xsWnmKXRx8fr2M87Vjx4xZ6C5nNvV985JzW HG8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ohYcK/h+3ibYka7ysojEKUGWGgYiFqj771QZXpbZi94=; b=HeIZXhljeHjUVthCcWiXJ8TOywAnFGYrYfdMOc+2vFsKcO6XRhaZPTOAjoYfwSs1tq TWdvMX/Qpaj4dL6/oOrnHXr2jXtsPE3zTL/V7lI0emhBpdFL22ihKVnPyLy+yQvpKxI7 1ec/i0iNuwZRsnqhkEWBRUGotmdK31zq+LJs/9iXHNjM1YOTL69vPcfH9b6B5Q8E2nb0 DEnd67a5Ifxsi71g8r6WmvCsgIRL5sCNlUWab6ralGfj+bhS7DxVnOoO6/xrJ4hVfpca LysaqssNJ2MS+8XHPwhnJEmyey6QAZpTWQN8KLnaSULODWV5Dgip6sLJa9QakSQFfJjw PkWg== X-Gm-Message-State: AOAM533X3HesZeCAhvTioH9iayB06XHUliatfeuu3doWnxZ8PJxFP3Qn Py6PGTulbO59B+d1sSEkYheN7TU/OZg= X-Google-Smtp-Source: ABdhPJzBUUMvLR6yq0m4bGi50cS3ZlUC2olXxH2tMau3GeWIshElW3jmaxBZoofS01WXDc92mvu6Ow== X-Received: by 2002:a17:906:2613:: with SMTP id h19mr6747777ejc.66.1632833499137; Tue, 28 Sep 2021 05:51:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 26/33] target/i386: Add the query-sgx-capabilities QMP command Date: Tue, 28 Sep 2021 14:51:09 +0200 Message-Id: <20210928125116.183620-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632836163188100001 Content-Type: text/plain; charset="utf-8" From: Yang Zhong Libvirt can use query-sgx-capabilities to get the host sgx capabilities to decide how to allocate SGX EPC size to VM. Signed-off-by: Yang Zhong Message-Id: <20210910102258.46648-3-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/sgx-stub.c | 6 ++++ hw/i386/sgx.c | 66 ++++++++++++++++++++++++++++++++++++++ include/hw/i386/sgx.h | 1 + qapi/misc-target.json | 18 +++++++++++ target/i386/monitor.c | 5 +++ tests/qtest/qmp-cmd-test.c | 1 + 6 files changed, 97 insertions(+) diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c index 485e16ecc1..3be9f5ca32 100644 --- a/hw/i386/sgx-stub.c +++ b/hw/i386/sgx-stub.c @@ -9,6 +9,12 @@ SGXInfo *sgx_get_info(Error **errp) return NULL; } =20 +SGXInfo *sgx_get_capabilities(Error **errp) +{ + error_setg(errp, "SGX support is not compiled in"); + return NULL; +} + void pc_machine_init_sgx_epc(PCMachineState *pcms) { memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState)); diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c index ea75398575..e481e9358f 100644 --- a/hw/i386/sgx.c +++ b/hw/i386/sgx.c @@ -18,6 +18,72 @@ #include "qapi/error.h" #include "exec/address-spaces.h" #include "hw/i386/sgx.h" +#include "sysemu/hw_accel.h" + +#define SGX_MAX_EPC_SECTIONS 8 +#define SGX_CPUID_EPC_INVALID 0x0 + +/* A valid EPC section. */ +#define SGX_CPUID_EPC_SECTION 0x1 +#define SGX_CPUID_EPC_MASK 0xF + +static uint64_t sgx_calc_section_metric(uint64_t low, uint64_t high) +{ + return (low & MAKE_64BIT_MASK(12, 20)) + + ((high & MAKE_64BIT_MASK(0, 20)) << 32); +} + +static uint64_t sgx_calc_host_epc_section_size(void) +{ + uint32_t i, type; + uint32_t eax, ebx, ecx, edx; + uint64_t size =3D 0; + + for (i =3D 0; i < SGX_MAX_EPC_SECTIONS; i++) { + host_cpuid(0x12, i + 2, &eax, &ebx, &ecx, &edx); + + type =3D eax & SGX_CPUID_EPC_MASK; + if (type =3D=3D SGX_CPUID_EPC_INVALID) { + break; + } + + if (type !=3D SGX_CPUID_EPC_SECTION) { + break; + } + + size +=3D sgx_calc_section_metric(ecx, edx); + } + + return size; +} + +SGXInfo *sgx_get_capabilities(Error **errp) +{ + SGXInfo *info =3D NULL; + uint32_t eax, ebx, ecx, edx; + + int fd =3D qemu_open_old("/dev/sgx_vepc", O_RDWR); + if (fd < 0) { + error_setg(errp, "SGX is not enabled in KVM"); + return NULL; + } + + info =3D g_new0(SGXInfo, 1); + host_cpuid(0x7, 0, &eax, &ebx, &ecx, &edx); + + info->sgx =3D ebx & (1U << 2) ? true : false; + info->flc =3D ecx & (1U << 30) ? true : false; + + host_cpuid(0x12, 0, &eax, &ebx, &ecx, &edx); + info->sgx1 =3D eax & (1U << 0) ? true : false; + info->sgx2 =3D eax & (1U << 1) ? true : false; + + info->section_size =3D sgx_calc_host_epc_section_size(); + + close(fd); + + return info; +} =20 SGXInfo *sgx_get_info(Error **errp) { diff --git a/include/hw/i386/sgx.h b/include/hw/i386/sgx.h index 2bf90b3f4f..16fc25725c 100644 --- a/include/hw/i386/sgx.h +++ b/include/hw/i386/sgx.h @@ -7,5 +7,6 @@ #include "qapi/qapi-types-misc-target.h" =20 SGXInfo *sgx_get_info(Error **errp); +SGXInfo *sgx_get_capabilities(Error **errp); =20 #endif diff --git a/qapi/misc-target.json b/qapi/misc-target.json index e2a347cc23..594fbd1577 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -376,3 +376,21 @@ # ## { 'command': 'query-sgx', 'returns': 'SGXInfo', 'if': 'TARGET_I386' } + +## +# @query-sgx-capabilities: +# +# Returns information from host SGX capabilities +# +# Returns: @SGXInfo +# +# Since: 6.2 +# +# Example: +# +# -> { "execute": "query-sgx-capabilities" } +# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true, +# "flc": true, "section-size" : 0 } } +# +## +{ 'command': 'query-sgx-capabilities', 'returns': 'SGXInfo', 'if': 'TARGET= _I386' } diff --git a/target/i386/monitor.c b/target/i386/monitor.c index d7384ba348..196c1c9e77 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -790,3 +790,8 @@ void hmp_info_sgx(Monitor *mon, const QDict *qdict) monitor_printf(mon, "size: %" PRIu64 "\n", info->section_size); } + +SGXInfo *qmp_query_sgx_capabilities(Error **errp) +{ + return sgx_get_capabilities(errp); +} diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index b75f3364f3..1af2f74c28 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -101,6 +101,7 @@ static bool query_is_ignored(const char *cmd) "query-sev", "query-sev-capabilities", "query-sgx", + "query-sgx-capabilities", NULL }; int i; --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835101237278.3826356418929; Tue, 28 Sep 2021 06:18:21 -0700 (PDT) Received: from localhost ([::1]:59760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD00-0001Hy-5P for importer@patchew.org; Tue, 28 Sep 2021 09:18:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaI-0006gN-RH for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:41960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0001UU-Do for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: by mail-ed1-x52d.google.com with SMTP id s17so64110345edd.8 for ; Tue, 28 Sep 2021 05:51:40 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cz69+LB8vyHglkWeQaZaWYrHPHHMp6AioMXJRYKgxG0=; b=E5IQLxfRVy0wpjxMXq8Ci9s4IRmu3xrHEqOUu+aqmsnXHXeJyv+Dhm/hhd542iVU/T krA2Z1HIJhqw5xOhwErUl7rScSuYq+RQKu8eSHnLATgQnlzFgMz0sEXt6r1nE96r+jlx L3PQCACS9jxhi8kgXOaZvStop3Co7fv852HLnAgdxdR421MM7DGBR6g/UD4oFdjt+FEY OKiCKnS9t3W8z5vRPtg0gomnTZcGHJQHQwLwpnUN93L/PS9MgFiOaZVFf7KnOU3+9ABb 47KBZ6/Wa72ceoNh36WJc0tfWDq/0XKcsmxkX9Z0tE3yPO9Qne7FAox0nb9XYVC4H/Ci uZDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Cz69+LB8vyHglkWeQaZaWYrHPHHMp6AioMXJRYKgxG0=; b=OyVVkpSNh6JzEaqu3FUn1Zy4dkBtFl0rUd/lqtC+rtlVOa+0qE2/rFBBWopY4cHhk7 TiSpcH49HshzlZ2OOifKfLSDOWm4yoiVLpkLCIctXOHwELi4mLNgD50yOk2oeT1ZraMI XD06GuPZ0eYMR12wTPwgMFFVfnsNV/29WniD2fKLQPmApzca0DbBmJtYQhb7exPpZNuI vSFLhCia05k8ItrOocds5YwHO1EppwKTIfyZ50E5OBOa8zoosJTrF2FI5bneGyI6LXdz PCsBkRr5NeFcWZ4S+lvr8L3/64erQV1iC5/n0k0v0LPx+qD15igP9wabJDhZvMvToxoq Hw7g== X-Gm-Message-State: AOAM533cIv+f3lTA1B7XhipLHaNBlAdHxxBF8LyrqFZQlUT2lCdm6teH LH3xm8shccVlkEzPqHqs/UvcsxqIxHE= X-Google-Smtp-Source: ABdhPJzjnCR7dixdxGqEd8fOAXDaa0oEfe7MTL85sy+Ge7nX6OKaU13XgJYUDLvyecTpebfUudbO/g== X-Received: by 2002:aa7:d303:: with SMTP id p3mr7542062edq.174.1632833499700; Tue, 28 Sep 2021 05:51:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 27/33] meson: unpack edk2 firmware even if --disable-blobs Date: Tue, 28 Sep 2021 14:51:10 +0200 Message-Id: <20210928125116.183620-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835102380100001 Content-Type: text/plain; charset="utf-8" The edk2 firmware blobs are needed to run bios-tables-test. Unpack them if any UEFI-enabled target is selected, so that the test can run. This is a bit more than is actually necessary, since bios-tables-test does not run for all UEFI-enabled targets, but it is the easiest way to write this logic. Signed-off-by: Paolo Bonzini Message-Id: <20210923105529.3845741-1-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- meson.build | 16 ++++++++-------- pc-bios/descriptors/meson.build | 4 ++-- pc-bios/meson.build | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 15ef4d3c41..978e8329f7 100644 --- a/meson.build +++ b/meson.build @@ -106,14 +106,14 @@ if targetos !=3D 'darwin' endif =20 edk2_targets =3D [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_= 64-softmmu' ] -install_edk2_blobs =3D false -if get_option('install_blobs') - foreach target : target_dirs - install_edk2_blobs =3D install_edk2_blobs or target in edk2_targets - endforeach -endif - -bzip2 =3D find_program('bzip2', required: install_edk2_blobs) +unpack_edk2_blobs =3D false +foreach target : edk2_targets + if target in target_dirs + bzip2 =3D find_program('bzip2', required: get_option('install_blobs')) + unpack_edk2_blobs =3D bzip2.found() + break + endif +endforeach =20 ################## # Compiler flags # diff --git a/pc-bios/descriptors/meson.build b/pc-bios/descriptors/meson.bu= ild index 29efa16d99..66f85d01c4 100644 --- a/pc-bios/descriptors/meson.build +++ b/pc-bios/descriptors/meson.build @@ -1,4 +1,4 @@ -if install_edk2_blobs +if unpack_edk2_blobs and get_option('install_blobs') foreach f: [ '50-edk2-i386-secure.json', '50-edk2-x86_64-secure.json', @@ -10,7 +10,7 @@ if install_edk2_blobs configure_file(input: files(f), output: f, configuration: {'DATADIR': get_option('prefix') / qemu_= datadir}, - install: get_option('install_blobs'), + install: true, install_dir: qemu_datadir / 'firmware') endforeach endif diff --git a/pc-bios/meson.build b/pc-bios/meson.build index f2b32598af..a3b3d87891 100644 --- a/pc-bios/meson.build +++ b/pc-bios/meson.build @@ -1,4 +1,4 @@ -if install_edk2_blobs +if unpack_edk2_blobs fds =3D [ 'edk2-aarch64-code.fd', 'edk2-arm-code.fd', --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163283491614585.32076957361835; Tue, 28 Sep 2021 06:15:16 -0700 (PDT) Received: from localhost ([::1]:52488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCx1-0004lG-5f for importer@patchew.org; Tue, 28 Sep 2021 09:15:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaJ-0006gh-2w for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:40550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaG-0001VM-Fp for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:46 -0400 Received: by mail-ed1-x52d.google.com with SMTP id g8so82855808edt.7 for ; Tue, 28 Sep 2021 05:51:42 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uaWUay8u5sEHfBZcOQ3gcsDVPBZYoTEkLnbi0ceKMYg=; b=R8R5WberBR4TFCJJsROYt3HFjlvQAzH6wurAEsQP8sxLX8m49pkTiIywMil4dItBal s+RsGZ22Ug5mBjZB+pAY5smcvWXW3VCE4Pmj4B2eLLfdXtwJC3VTsC7D0FSYPuMhWfRp t3hYRE2CmMvG4enOGIF3F4N39w4CiMORuQtYnVtOLBQS4uriHhTw2aBZjaAHj5VeGtfp dAraygLg0qClVBWQZ+gMyDeCWMloLahtIbHAOPDeiFyBd/4ZiuXpxbZaHuACDo/2/P6h jtRxkti4I9pRfOu6QcYXluGUBUuhOYgv8auqroQbNzdW7mB9usJt5vfinmdHNsWJvEq6 kwbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=uaWUay8u5sEHfBZcOQ3gcsDVPBZYoTEkLnbi0ceKMYg=; b=Ic80lREkPcNfoN7HhlvqW8rWrR8ztDJNpsp745hgduZPWu6ZLFXRiCBNRhOF0EjdAc z5LceON1mMDtUYO7f7SJSk1kcqtAd79XIXJxXzfk+EHmodHbNYtvj6LgbBVx76z4ic+d jH//jQtxkeAwjxl+JFo7Ae0mnRDb8ipca/RemrsZO9ov2jbvAtoPMntCdMTbkL/Br8Bm wtULfTecbLrcD7UdCxySRnd4rhzCpClwQMgyOu0NKpUPS6STR4FU8SCFHmBMJIkclTEq 6icmuYfpYl+LCYHGy0Qia4Lx0h6a67dcuOmTixLFLG4h0lf55+3EYuF/j4pb3ZiIzp/8 IsuA== X-Gm-Message-State: AOAM5324I0Xh2RuI5bO+M/AkUuv2YxCE2J1J2TGu2iQ4B2mJZhM0z6j3 /hmSDAj5MMfrT+L5zdN+4UWKhroJcCU= X-Google-Smtp-Source: ABdhPJwvtgnEqVoIyCCVdVt4VPWv1g4S4EEjsAhHXj1I2XMusiRGdhJRtjDdyJw/TynLQdXGOplxeg== X-Received: by 2002:a17:906:3882:: with SMTP id q2mr6670379ejd.396.1632833500447; Tue, 28 Sep 2021 05:51:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 28/33] tests: qtest: bios-tables-test depends on the unpacked edk2 ROMs Date: Tue, 28 Sep 2021 14:51:11 +0200 Message-Id: <20210928125116.183620-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834917646100001 Content-Type: text/plain; charset="utf-8" Skip the test if bzip2 is not available, and run it after they are uncompressed. Signed-off-by: Paolo Bonzini Message-Id: <20210923105529.3845741-2-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- pc-bios/meson.build | 3 ++- tests/qtest/meson.build | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pc-bios/meson.build b/pc-bios/meson.build index a3b3d87891..a44c9bc127 100644 --- a/pc-bios/meson.build +++ b/pc-bios/meson.build @@ -1,3 +1,4 @@ +roms =3D [] if unpack_edk2_blobs fds =3D [ 'edk2-aarch64-code.fd', @@ -11,7 +12,7 @@ if unpack_edk2_blobs ] =20 foreach f : fds - custom_target(f, + roms +=3D custom_target(f, build_by_default: have_system, output: f, input: '@0@.bz2'.format(f), diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 757bb8499a..19444d4752 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -68,12 +68,12 @@ qtests_i386 =3D \ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : [= ]) + \ (config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ? ['fuzz-e1000e= -test'] : []) + \ (config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) = + \ + (unpack_edk2_blobs ? ['bios-tables-test'] : []) + = \ qtests_pci + = \ ['fdc-test', 'ide-test', 'hd-geo-test', 'boot-order-test', - 'bios-tables-test', 'rtc-test', 'i440fx-test', 'fw_cfg-test', @@ -180,7 +180,7 @@ qtests_arm =3D \ =20 # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-tes= t unconditional qtests_aarch64 =3D \ - (cpu !=3D 'arm' ? ['bios-tables-test'] : []) + = \ + (cpu !=3D 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + = \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-= test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-= swtpm-test'] : []) + \ ['arm-cpu-features', @@ -269,7 +269,7 @@ foreach dir : target_dirs qtest_emulator =3D emulators['qemu-system-' + target_base] target_qtests =3D get_variable('qtests_' + target_base, []) + qtests_gen= eric =20 - test_deps =3D [] + test_deps =3D roms qtest_env =3D environment() if have_tools qtest_env.set('QTEST_QEMU_IMG', './qemu-img') --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835628730140.97673538256322; Tue, 28 Sep 2021 06:27:08 -0700 (PDT) Received: from localhost ([::1]:48680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD8T-0004fl-OW for importer@patchew.org; Tue, 28 Sep 2021 09:27:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaM-0006gs-De for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:44890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaL-0001Yf-01 for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:50 -0400 Received: by mail-ed1-x535.google.com with SMTP id v18so47488346edc.11 for ; Tue, 28 Sep 2021 05:51:48 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hagtKSKeymEdKzgkRVDA/CGvBVgxGAcG0lg165ITsKM=; b=Ebb3lRNs/9hMdZ171UUJt0/7ti+KPSwu4BSU7jxoyK3gDV19UBqeqRKBe8AiZzpRjY gzwYRzxq1P/L6uWYmDL2K/rye7cRAq1E4gmNXnvJTuuVLr5sEG6FvXX3cns517eFTJfp RsXONxsgcibDpxZV+IJgPRbms3DXNuUSvJYgksuSWolKh3eIFgegdXLL9B5M+UZTP18Z kSUytmiyKjuWZ1xo/UEEWz6RYZZ3CXsbvV02pm8x60eqS0BepwZPerM3pxR63SpUTKXC 0HcttW9+gaWmncXZZoxOfiAkBig7zJjyTvLSAbxNC7tFgP4AW4/mejXJxjV941RPb+G6 cnDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=hagtKSKeymEdKzgkRVDA/CGvBVgxGAcG0lg165ITsKM=; b=49b+iigKaJ6g1lm4Aukjf3aqkUIWKU67mJBBfc20UP+kmEUGQm/krzUH422BhOFZIF RCs1SDrKRbf2eedztIY5WQg0FvGfBLlSGRgWWKCZLR1hOqwnr0a3IOOuQepeDYpzfrRb hXOij4iatVwHhlgp65CBO/O/LoxI0hJrjfZn8hkCwrTfkaH1B+ccaN9/FrNM/usWSW7D LGJTmuB3lCnmuoaelmI6DBNxKxF4f60CUMipufTjB8lpi9HrxG/cnf/tBJcdRq/P9YDa aisG9Hf13/c3kCGpoC3DU/tmcwHh9sI2lf04JNeX5QVUP2x4cihM+yAmm3B/YIpD1tJC 9Dfg== X-Gm-Message-State: AOAM532bBe4UUDWedacgEx/bE5izEnaq64isy5fBIDNfihwEg6GM/Mnm XUALJovv9wo1Wqk2cCT8DhR2tKyEV5Q= X-Google-Smtp-Source: ABdhPJxZUkupMtW8Rkb9JD0v+E83fqNzeMX2OTGElwz8dTIsHdn5PAu/NVbn++yKK47cOhK3NrKV4A== X-Received: by 2002:a17:907:960f:: with SMTP id gb15mr1742004ejc.460.1632833501069; Tue, 28 Sep 2021 05:51:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 29/33] target/i386: Fix memory leak in sev_read_file_base64() Date: Tue, 28 Sep 2021 14:51:12 +0200 Message-Id: <20210928125116.183620-30-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835629410100001 From: Peter Maydell In sev_read_file_base64() we call g_file_get_contents(), which allocates memory for the file contents. We then base64-decode the contents (which allocates another buffer for the decoded data), but forgot to free the memory for the original file data. Use g_autofree to ensure that the file data is freed. Fixes: Coverity CID 1459997 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210820165650.2839-1-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 0b2c8f594a..fa7210473a 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -565,7 +565,7 @@ static int sev_read_file_base64(const char *filename, guchar **data, gsize *len) { gsize sz; - gchar *base64; + g_autofree gchar *base64 =3D NULL; GError *error =3D NULL; =20 if (!g_file_get_contents(filename, &base64, &sz, &error)) { --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632834707184448.7204183381782; Tue, 28 Sep 2021 06:11:47 -0700 (PDT) Received: from localhost ([::1]:43878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVCtc-0007Aw-Bh for importer@patchew.org; Tue, 28 Sep 2021 09:11:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaL-0006go-7E for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:37546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaJ-0001XR-Av for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:49 -0400 Received: by mail-ed1-x52f.google.com with SMTP id ba1so24898632edb.4 for ; Tue, 28 Sep 2021 05:51:46 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wa0TczWrJRWfuwrLLq+Ir9rEkx82edYO7rT2p35STvk=; b=GP6otkpksotKQ35Y6L2I+E4ea7BonlBbjmK60W2rS8JwftKL8GxTEOoXYm4ccvYjcd LAQTb7b3pdo9URT4eubeUu2tbdPXL63j6SsYJMzMi6hWAJ8n/hEVuAw1MuTdroyez6oa Vk+5wX8A52v2wm4ODNiEFThSkUGlu8vg6SuiiYBzTdqWOs8+c4xlkUkbi88A8nNOHniL yaGt6NdywWy6/ylKnIvrorjnmKnlVhWEeo2W1g8F/CdowFdlX/bBvnqudok4abdnFi2q /NBusywD26j4YkI8GV8Z3xb6DpWP/i5C7bSVFyrdEfEa2DEgJwwiEe5VWKQ9rRwdoApy m1Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Wa0TczWrJRWfuwrLLq+Ir9rEkx82edYO7rT2p35STvk=; b=RLquaN27Mm6Lc0DijRGU/Lp0zSwsKsvOsXPcSczj82WhipJSOSWMeZ2JkBDGBiLA0D ywdrQNrxAbqLVKSweGo6BnzQSkwg+UGwkiSkK24uU5x7zkatj1y4yVnxFx5GgA0rXA51 CsODegL5P1sL3tqMYciqg1LRX5KtmvvHR0q2RLgRVrC+rV4CVU4gEDW1Tw6L1JD/vOga crULDl5YpEioNaIrhukaRrt9C2x88uA42fb6euEdgzjZEtENdIAl4DKFRMoL9E5LjOS6 NcYL/sUJed2moYpUumiJCoNhN4qECh8gO33+vUF/7jMv1Kzv23raIr+AgrKV9txLCQiU qxAQ== X-Gm-Message-State: AOAM533s015F5/8p9OoFOxzwAN4cRV1puFDpc/JhBknGhVbH7FmEq0Q2 0vJnRNgZ6RwnSggP6f/Ii8Oj042Nt7I= X-Google-Smtp-Source: ABdhPJy+2q+YPTWVAYIaiLjgYrYcof9sWMW3PRtmdABMHWQNmyeb/Ai+jZZ0Dh3s1qXiRldBWvVaBw== X-Received: by 2002:a50:bf07:: with SMTP id f7mr7405467edk.288.1632833501958; Tue, 28 Sep 2021 05:51:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 30/33] memory: Name all the memory listeners Date: Tue, 28 Sep 2021 14:51:13 +0200 Message-Id: <20210928125116.183620-31-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632834707765100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Provide a name field for all the memory listeners. It can be used to ident= ify which memory listener is which. Signed-off-by: Peter Xu Reviewed-by: David Hildenbrand Message-Id: <20210817013553.30584-2-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- accel/hvf/hvf-accel-ops.c | 1 + accel/kvm/kvm-all.c | 7 +++++-- hw/i386/xen/xen-hvm.c | 2 ++ hw/intc/openpic_kvm.c | 1 + hw/remote/proxy-memory-listener.c | 1 + hw/vfio/common.c | 1 + hw/vfio/spapr.c | 1 + hw/virtio/vhost-vdpa.c | 1 + hw/virtio/vhost.c | 2 ++ hw/virtio/virtio.c | 1 + hw/xen/xen_pt.c | 2 ++ include/exec/memory.h | 8 ++++++++ include/sysemu/kvm_int.h | 2 +- softmmu/physmem.c | 1 + target/arm/kvm.c | 1 + target/i386/hax/hax-mem.c | 1 + target/i386/kvm/kvm.c | 2 +- target/i386/nvmm/nvmm-all.c | 1 + target/i386/whpx/whpx-all.c | 1 + 19 files changed, 33 insertions(+), 4 deletions(-) diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 93976f4ece..6cbd2c3f97 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -295,6 +295,7 @@ static void hvf_region_del(MemoryListener *listener, } =20 static MemoryListener hvf_memory_listener =3D { + .name =3D "hvf", .priority =3D 10, .region_add =3D hvf_region_add, .region_del =3D hvf_region_del, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index cace5ffe64..db8d83b137 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1129,6 +1129,7 @@ static void kvm_coalesce_pio_del(MemoryListener *list= ener, } =20 static MemoryListener kvm_coalesced_pio_listener =3D { + .name =3D "kvm-coalesced-pio", .coalesced_io_add =3D kvm_coalesce_pio_add, .coalesced_io_del =3D kvm_coalesce_pio_del, }; @@ -1633,7 +1634,7 @@ static void kvm_io_ioeventfd_del(MemoryListener *list= ener, } =20 void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, - AddressSpace *as, int as_id) + AddressSpace *as, int as_id, const char = *name) { int i; =20 @@ -1649,6 +1650,7 @@ void kvm_memory_listener_register(KVMState *s, KVMMem= oryListener *kml, kml->listener.log_start =3D kvm_log_start; kml->listener.log_stop =3D kvm_log_stop; kml->listener.priority =3D 10; + kml->listener.name =3D name; =20 if (s->kvm_dirty_ring_size) { kml->listener.log_sync_global =3D kvm_log_sync_global; @@ -1669,6 +1671,7 @@ void kvm_memory_listener_register(KVMState *s, KVMMem= oryListener *kml, } =20 static MemoryListener kvm_io_listener =3D { + .name =3D "kvm-io", .eventfd_add =3D kvm_io_ioeventfd_add, .eventfd_del =3D kvm_io_ioeventfd_del, .priority =3D 10, @@ -2579,7 +2582,7 @@ static int kvm_init(MachineState *ms) s->memory_listener.listener.coalesced_io_del =3D kvm_uncoalesce_mmio_r= egion; =20 kvm_memory_listener_register(s, &s->memory_listener, - &address_space_memory, 0); + &address_space_memory, 0, "kvm-memory"); if (kvm_eventfds_allowed) { memory_listener_register(&kvm_io_listener, &address_space_io); diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 9b432773f0..e3d3d5cf89 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -721,6 +721,7 @@ static void xen_log_global_stop(MemoryListener *listene= r) } =20 static MemoryListener xen_memory_listener =3D { + .name =3D "xen-memory", .region_add =3D xen_region_add, .region_del =3D xen_region_del, .log_start =3D xen_log_start, @@ -732,6 +733,7 @@ static MemoryListener xen_memory_listener =3D { }; =20 static MemoryListener xen_io_listener =3D { + .name =3D "xen-io", .region_add =3D xen_io_add, .region_del =3D xen_io_del, .priority =3D 10, diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index 21da680389..557dd0c2bf 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -234,6 +234,7 @@ static void kvm_openpic_realize(DeviceState *dev, Error= **errp) =20 opp->mem_listener.region_add =3D kvm_openpic_region_add; opp->mem_listener.region_del =3D kvm_openpic_region_del; + opp->mem_listener.name =3D "openpic-kvm"; memory_listener_register(&opp->mem_listener, &address_space_memory); =20 /* indicate pic capabilities */ diff --git a/hw/remote/proxy-memory-listener.c b/hw/remote/proxy-memory-lis= tener.c index 901dbf1357..882c9b4854 100644 --- a/hw/remote/proxy-memory-listener.c +++ b/hw/remote/proxy-memory-listener.c @@ -219,6 +219,7 @@ void proxy_memory_listener_configure(ProxyMemoryListene= r *proxy_listener, proxy_listener->listener.region_add =3D proxy_memory_listener_region_a= ddnop; proxy_listener->listener.region_nop =3D proxy_memory_listener_region_a= ddnop; proxy_listener->listener.priority =3D 10; + proxy_listener->listener.name =3D "proxy"; =20 memory_listener_register(&proxy_listener->listener, &address_space_memory); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 1289cfa8be..a784b219e6 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1435,6 +1435,7 @@ static void vfio_listener_log_sync(MemoryListener *li= stener, } =20 static const MemoryListener vfio_memory_listener =3D { + .name =3D "vfio", .region_add =3D vfio_listener_region_add, .region_del =3D vfio_listener_region_del, .log_global_start =3D vfio_listener_log_global_start, diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index ea3f70bd2f..04c6e67f8f 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -136,6 +136,7 @@ static void vfio_prereg_listener_region_del(MemoryListe= ner *listener, } =20 const MemoryListener vfio_prereg_listener =3D { + .name =3D "vfio-pre-reg", .region_add =3D vfio_prereg_listener_region_add, .region_del =3D vfio_prereg_listener_region_del, }; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7633ea66d1..47d7a5a23d 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -246,6 +246,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, * depends on the addnop(). */ static const MemoryListener vhost_vdpa_memory_listener =3D { + .name =3D "vhost-vdpa", .commit =3D vhost_vdpa_listener_commit, .region_add =3D vhost_vdpa_listener_region_add, .region_del =3D vhost_vdpa_listener_region_del, diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index b4b29413e6..437347ad01 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1366,6 +1366,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, hdev->features =3D features; =20 hdev->memory_listener =3D (MemoryListener) { + .name =3D "vhost", .begin =3D vhost_begin, .commit =3D vhost_commit, .region_add =3D vhost_region_addnop, @@ -1381,6 +1382,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, }; =20 hdev->iommu_listener =3D (MemoryListener) { + .name =3D "vhost-iommu", .region_add =3D vhost_iommu_region_add, .region_del =3D vhost_iommu_region_del, }; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3a1f6c520c..240759ff0b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3670,6 +3670,7 @@ static void virtio_device_realize(DeviceState *dev, E= rror **errp) } =20 vdev->listener.commit =3D virtio_memory_listener_commit; + vdev->listener.name =3D "virtio"; memory_listener_register(&vdev->listener, vdev->dma_as); } =20 diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 232482d65f..ca0a98187e 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -689,12 +689,14 @@ static void xen_pt_io_region_del(MemoryListener *l, M= emoryRegionSection *sec) } =20 static const MemoryListener xen_pt_memory_listener =3D { + .name =3D "xen-pt-mem", .region_add =3D xen_pt_region_add, .region_del =3D xen_pt_region_del, .priority =3D 10, }; =20 static const MemoryListener xen_pt_io_listener =3D { + .name =3D "xen-pt-io", .region_add =3D xen_pt_io_region_add, .region_del =3D xen_pt_io_region_del, .priority =3D 10, diff --git a/include/exec/memory.h b/include/exec/memory.h index 9446874d21..a185b6dcb8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -982,6 +982,14 @@ struct MemoryListener { */ unsigned priority; =20 + /** + * @name: + * + * Name of the listener. It can be used in contexts where we'd like to + * identify one memory listener with the rest. + */ + const char *name; + /* private: */ AddressSpace *address_space; QTAILQ_ENTRY(MemoryListener) link; diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index c788452cd9..1f5487d9b7 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -37,7 +37,7 @@ typedef struct KVMMemoryListener { } KVMMemoryListener; =20 void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, - AddressSpace *as, int as_id); + AddressSpace *as, int as_id, const char = *name); =20 void kvm_set_max_memslot_size(hwaddr max_slot_size); =20 diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 088660d973..f67ad29981 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -756,6 +756,7 @@ void cpu_address_space_init(CPUState *cpu, int asidx, if (tcg_enabled()) { newas->tcg_as_listener.log_global_after_sync =3D tcg_log_global_af= ter_sync; newas->tcg_as_listener.commit =3D tcg_commit; + newas->tcg_as_listener.name =3D "tcg"; memory_listener_register(&newas->tcg_as_listener, as); } } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 94b970bbf9..bbf1ce7ba3 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -335,6 +335,7 @@ static void kvm_arm_devlistener_del(MemoryListener *lis= tener, } =20 static MemoryListener devlistener =3D { + .name =3D "kvm-arm", .region_add =3D kvm_arm_devlistener_add, .region_del =3D kvm_arm_devlistener_del, }; diff --git a/target/i386/hax/hax-mem.c b/target/i386/hax/hax-mem.c index 8d44edbffd..a226d174d8 100644 --- a/target/i386/hax/hax-mem.c +++ b/target/i386/hax/hax-mem.c @@ -285,6 +285,7 @@ static void hax_log_sync(MemoryListener *listener, } =20 static MemoryListener hax_memory_listener =3D { + .name =3D "hax", .begin =3D hax_transaction_begin, .commit =3D hax_transaction_commit, .region_add =3D hax_region_add, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index f6bbf33bc1..7f1b060e6d 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2248,7 +2248,7 @@ static void register_smram_listener(Notifier *n, void= *unused) =20 address_space_init(&smram_address_space, &smram_as_root, "KVM-SMRAM"); kvm_memory_listener_register(kvm_state, &smram_listener, - &smram_address_space, 1); + &smram_address_space, 1, "kvm-smram"); } =20 int kvm_arch_init(MachineState *ms, KVMState *s) diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index a488b00e90..14c996f968 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -1123,6 +1123,7 @@ nvmm_log_sync(MemoryListener *listener, MemoryRegionS= ection *section) } =20 static MemoryListener nvmm_memory_listener =3D { + .name =3D "nvmm", .begin =3D nvmm_transaction_begin, .commit =3D nvmm_transaction_commit, .region_add =3D nvmm_region_add, diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 3e925b9da7..ef896da0a2 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1598,6 +1598,7 @@ static void whpx_log_sync(MemoryListener *listener, } =20 static MemoryListener whpx_memory_listener =3D { + .name =3D "whpx", .begin =3D whpx_transaction_begin, .commit =3D whpx_transaction_commit, .region_add =3D whpx_region_add, --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835135175707.6896871058848; Tue, 28 Sep 2021 06:18:55 -0700 (PDT) Received: from localhost ([::1]:32790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD0Y-0002A6-07 for importer@patchew.org; Tue, 28 Sep 2021 09:18:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaJ-0006gl-Fv for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:39688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaH-0001WZ-ON for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:47 -0400 Received: by mail-ed1-x529.google.com with SMTP id x7so68158377edd.6 for ; Tue, 28 Sep 2021 05:51:45 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BM+iD1PcwtRETlHUjTXSADa0Dlink82Tdo9tl/Wyh+U=; b=htg23bmCMM58/B2zrQAuD8RM+vDhUJqGSmGpaNqMZ9yWfWL7aR+5Pm7xvZ5Ic5cdsg TCr3cSnxzLb1V4wnAaI0a+t0ZEGx0wl37oNGqlpxx0RkYkskFVQmY0XzkOQnT6NT3XWD WiuQGeTOFAzXRffnogVq5XMGudHWK9JXY1eS2Ocyq9QV5SbeNTg7LA0b6e5zWe7AoTxL /+y4E9ZJ06AP1JiftcTUn3vRdrt6XgASQWNQtaDMCwqzNY/5X81MvuWpIvD0r8vSNHyJ JHCukAnl3g5Q1r1XKsHqAOsbm2xZl/khD4ignAku6UKjv0czocEH+FgNcW6qBpSNVUty JnZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BM+iD1PcwtRETlHUjTXSADa0Dlink82Tdo9tl/Wyh+U=; b=yqGCDpz5Ak1CEDNt1/oZk29XgkS/YvV1xKAYFcu+e2XO9u/aINXrmI8AOeKujm9Kqi nWcUCUew+BSWMghdF1MEB9fEN/1INDnoYLkX/D9d2QPSQYL4AOs17j+PbQmCEGaThoBw Y58OiHLpK60QiuJ1+qlTnhU5rbIJCIcNhUAaOASYAid8tU9ZduEbK2k6JeZyU90n3JYF 6VBpC6VOwhTXCcVFIoCr+iXghc9Pt2kJC7yr8vaXrEqDlml1G5Diz00STC40CP00IKRw 1JSahQd82b3pDT8zaRvVrkd5LqnZsUtVx8DCQU79k3VvOh8/HEX0e/gdnic/BvsAXRtk VZcQ== X-Gm-Message-State: AOAM533yhPhqKUgcoJ2W4Djjvbh/GNq7TAEXSlrStL5dbW3UzHlPenIc oLbXhFqNpcRhYIZ7SUQu6pS5zExCaOQ= X-Google-Smtp-Source: ABdhPJwftiKtSMCvKxwQxyrp5qjPLIw9gBIj+uMynUG/PP439c93tiOe+2bRNwuo4JlO8WWJbMBuEA== X-Received: by 2002:a17:906:bfe7:: with SMTP id vr7mr6524011ejb.32.1632833502545; Tue, 28 Sep 2021 05:51:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 31/33] memory: Add tracepoint for dirty sync Date: Tue, 28 Sep 2021 14:51:14 +0200 Message-Id: <20210928125116.183620-32-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835137492100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Trace at memory_region_sync_dirty_bitmap() for log_sync() or global_log_syn= c() on memory regions. One trace line should suffice when it finishes, so as to estimate the time used for each log sync process. Signed-off-by: Peter Xu Message-Id: <20210817013706.30986-1-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- softmmu/memory.c | 2 ++ softmmu/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/softmmu/memory.c b/softmmu/memory.c index 54cd0e9824..db182e5d3d 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2154,6 +2154,7 @@ static void memory_region_sync_dirty_bitmap(MemoryReg= ion *mr) } } flatview_unref(view); + trace_memory_region_sync_dirty(mr ? mr->name : "(all)", listen= er->name, 0); } else if (listener->log_sync_global) { /* * No matter whether MR is specified, what we can do here @@ -2161,6 +2162,7 @@ static void memory_region_sync_dirty_bitmap(MemoryReg= ion *mr) * sync in a finer granularity. */ listener->log_sync_global(listener); + trace_memory_region_sync_dirty(mr ? mr->name : "(all)", listen= er->name, 1); } } } diff --git a/softmmu/trace-events b/softmmu/trace-events index 7b278590a0..bf1469990e 100644 --- a/softmmu/trace-events +++ b/softmmu/trace-events @@ -15,6 +15,7 @@ memory_region_subpage_read(int cpu_index, void *mr, uint6= 4_t offset, uint64_t va memory_region_subpage_write(int cpu_index, void *mr, uint64_t offset, uint= 64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx6= 4" size %u" memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint= 64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64"= size %u" memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uin= t64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64= " size %u" +memory_region_sync_dirty(const char *mr, const char *listener, int global)= "mr '%s' listener '%s' synced (global=3D%d)" flatview_new(void *view, void *root) "%p (root %p)" flatview_destroy(void *view, void *root) "%p (root %p)" flatview_destroy_rcu(void *view, void *root) "%p (root %p)" --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835418781792.7067380528742; Tue, 28 Sep 2021 06:23:38 -0700 (PDT) Received: from localhost ([::1]:43006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD57-0000jm-Ps for importer@patchew.org; Tue, 28 Sep 2021 09:23:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaL-0006gq-Up for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:37543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaK-0001Yi-Ed for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:49 -0400 Received: by mail-ed1-x52b.google.com with SMTP id ba1so24898811edb.4 for ; Tue, 28 Sep 2021 05:51:48 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H2j0w3zV2aYZRFejCWueKk3nNl/dRSroOVrcszJhoRY=; b=PvhJUJ84RY886qQJaDbCYRvAzEB7Abo5LtO/7Fwmjw4aE81IXs8IBKi3Vm6ZjYdmRR 1H3JqaG/FTy1YEHYTD+BP5GUkKqa52OWnF01wwoKhIIAFg9k6qtJeXfvf4OzUf3AKn8e 5Sk/orEprsn/Qgbtv5JBgtU0NB89AXGvPT1H+KhMbRLzLSm5VeV4mLM9cPjfeEGciFhY rZ5Mb8RvmnGNRsiqaYPA4Rs/Npbby5YmdtPoWeaX3speHuYKAXpgCOTgf5vX2qhqFRyI XLc4MlvBK+mpqhfauSAgQXC8UUppgCrneW36v8R1g/0HW/CLdo8jzqxmH9hB+nos01OJ a32Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=H2j0w3zV2aYZRFejCWueKk3nNl/dRSroOVrcszJhoRY=; b=5g/W6nwspV9biFS+Hp11rA1xAMnxwW2VVoujcz83dRyZIhAaabz2s3uDRCDQ/s+JtZ DGi/WkAaiTj2sAj8AbUJjgDfdGNgS+hH/hGLfG62KFeR4RT7l3XmOgsevLizQGEyFINF WaVNCSVI11W5P5aI+qXpm/XzQQjoKAZfGiGbVQPPORvmS5dgI89jsxttiPRdzGzWat/V sjOoDsUNbTKvxxzsLs6gc1BObVCJc4zjHV35Zk+x39AIsetFoQ5T/vtY/MufLe0g2Ho8 q0fTq++xObpDObe9ovcuGeLS0AwhjCJrc9GepSmqVGh2ckOV6vImfFMQk0U4pgY/1Yep Aqcg== X-Gm-Message-State: AOAM5331XsHa4Pl7IzBU8tIrBbHsqtpP4COSHlyw87tCxpejMeuOERnQ 5zt++sbvo1vG3f5FFHe8XARsJbpMDZs= X-Google-Smtp-Source: ABdhPJySug+ggOA7h908cfakAgy2A9QdE1t3j+VhMXUxylGbKEq5wnn9EXhnUW26EJq1glp4UwB7+Q== X-Received: by 2002:a17:906:169a:: with SMTP id s26mr6058248ejd.278.1632833503206; Tue, 28 Sep 2021 05:51:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 32/33] build-sys: add HAVE_IPPROTO_MPTCP Date: Tue, 28 Sep 2021 14:51:15 +0200 Message-Id: <20210928125116.183620-33-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835419073100001 From: Marc-Andr=C3=A9 Lureau The QAPI schema shouldn't rely on C system headers #define, but on configure-time project #define, so we can express the build condition in a C-independent way. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210907121943.3498701-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- io/dns-resolver.c | 2 +- meson.build | 2 ++ qapi/sockets.json | 2 +- util/qemu-sockets.c | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/io/dns-resolver.c b/io/dns-resolver.c index a5946a93bf..53b0e8407a 100644 --- a/io/dns-resolver.c +++ b/io/dns-resolver.c @@ -122,7 +122,7 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSReso= lver *resolver, .ipv4 =3D iaddr->ipv4, .has_ipv6 =3D iaddr->has_ipv6, .ipv6 =3D iaddr->ipv6, -#ifdef IPPROTO_MPTCP +#ifdef HAVE_IPPROTO_MPTCP .has_mptcp =3D iaddr->has_mptcp, .mptcp =3D iaddr->mptcp, #endif diff --git a/meson.build b/meson.build index 978e8329f7..7f0fafff4a 100644 --- a/meson.build +++ b/meson.build @@ -1374,6 +1374,8 @@ config_host_data.set('HAVE_OPTRESET', cc.has_header_symbol('getopt.h', 'optreset')) config_host_data.set('HAVE_UTMPX', cc.has_header_symbol('utmpx.h', 'struct utmpx')) +config_host_data.set('HAVE_IPPROTO_MPTCP', + cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP')) =20 # has_member config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID', diff --git a/qapi/sockets.json b/qapi/sockets.json index ef4b16d6f2..5773d9fcc4 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -69,7 +69,7 @@ '*ipv4': 'bool', '*ipv6': 'bool', '*keep-alive': 'bool', - '*mptcp': { 'type': 'bool', 'if': 'IPPROTO_MPTCP' } } } + '*mptcp': { 'type': 'bool', 'if': 'HAVE_IPPROTO_MPTCP' } } } =20 ## # @UnixSocketAddress: diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 72216ef980..0585e7a629 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -278,7 +278,7 @@ static int inet_listen_saddr(InetSocketAddress *saddr, =20 /* create socket + bind/listen */ for (e =3D res; e !=3D NULL; e =3D e->ai_next) { -#ifdef IPPROTO_MPTCP +#ifdef HAVE_IPPROTO_MPTCP if (saddr->has_mptcp && saddr->mptcp) { e->ai_protocol =3D IPPROTO_MPTCP; } @@ -462,7 +462,7 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error = **errp) error_free(local_err); local_err =3D NULL; =20 -#ifdef IPPROTO_MPTCP +#ifdef HAVE_IPPROTO_MPTCP if (saddr->has_mptcp && saddr->mptcp) { e->ai_protocol =3D IPPROTO_MPTCP; } @@ -699,7 +699,7 @@ int inet_parse(InetSocketAddress *addr, const char *str= , Error **errp) } addr->has_keep_alive =3D true; } -#ifdef IPPROTO_MPTCP +#ifdef HAVE_IPPROTO_MPTCP begin =3D strstr(optstr, ",mptcp"); if (begin) { if (inet_parse_flag("mptcp", begin + strlen(",mptcp"), --=20 2.31.1 From nobody Mon Feb 9 07:52:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1632835316021619.5250648176457; Tue, 28 Sep 2021 06:21:56 -0700 (PDT) Received: from localhost ([::1]:40092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVD3S-00078e-QW for importer@patchew.org; Tue, 28 Sep 2021 09:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVCaL-0006gp-Ki for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:51 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:36733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVCaK-0001YZ-6B for qemu-devel@nongnu.org; Tue, 28 Sep 2021 08:51:49 -0400 Received: by mail-ed1-x52c.google.com with SMTP id y35so31712255ede.3 for ; Tue, 28 Sep 2021 05:51:47 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p24sm12641685edq.27.2021.09.28.05.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 05:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R/zfYQqCX/9aRSWbJScPUII4oC13AO6Qw74gztGZOQI=; b=WvgEThNK65lL+570QaI+5vJXRYVcGXFwM3UrPpF5E3/ZvChecpPX1easMqZbUCfZPG YGiexAorse1MTgroDVbm/jdayD47Eq0qlYE/OuBXJ7/HPWolzzMVX8mQJUuYp2wExAHp NiYuY6cTpdzUYgH0mmfxA5ZSs9QXWfwJo6/CNBaooBW78TxB8tgUAaHkaET1XZyHkGnR kwqM4+bjQoBMdBUGae9uQXXVwxwE6IOqKaAn4a8VWGhA/gPGhziEUp6J/65YxkO7Q4J4 p8InhxHIwSr+Yifi65uJTHc0UOJaCoRuqqqzBT/xk7X6CQMVEI+NTBSfykgR7PbzGDRf 5OOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=R/zfYQqCX/9aRSWbJScPUII4oC13AO6Qw74gztGZOQI=; b=6cC/7rt4jOCZ6cIBABuBeSDogwDbmk3ptuQ9MfX32BjXufHw5kkBbe6tIZB54m4+X0 t7JHxEnqteoplSu29DRTupRsXGlPId5mOpW9EEzk2R8r5FC/80NBXaQGwmGErkvXE9O4 ni11o5+4Kbd80LDojjbBz4Rx4JleZtdowTXmtokBRenjtlmxlVQaI5gmuju4/1F5B1/t z2gTD5QYk/iE4h80587xcvYcDeZYPQRe91kO5BsPbXJmhPSMSLLv5FK3WeKd09IRaAoA F+lAVPhs+xNo3Iyg/epByWIzaBK85jLs46Pa/1gT3iw7R1LFNkoKerA53Z5Q+MK1e4zX HT/g== X-Gm-Message-State: AOAM531mYRfcjqLHjF+swhMq+X4LOGU9SmzHNsJR4Xr5BbKQyoPZ1i5l HIwlFM7mIZOwEMuReWUeUaDhHYN4+SA= X-Google-Smtp-Source: ABdhPJw1/yHl+G0vuFt0i5GQc07xt3G/6hk922PBHa7moadkpsiUPwnwjFmYqTiYkcmTEf6oRiUC5w== X-Received: by 2002:a17:906:12d4:: with SMTP id l20mr6065582ejb.43.1632833503947; Tue, 28 Sep 2021 05:51:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 33/33] meson_options.txt: Switch the default value for the vnc option to 'auto' Date: Tue, 28 Sep 2021 14:51:16 +0200 Message-Id: <20210928125116.183620-34-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210928125116.183620-1-pbonzini@redhat.com> References: <20210928125116.183620-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1632835318263100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth There is no reason why VNC should always be enabled and not be set to the default value. We already switched the setting in the "configure" script in commit 3a6a1256d4 ("configure: Allow vnc to get disabled with --without-default-features"), so let's do that in meson_options.txt now, too. Signed-off-by: Thomas Huth Reviewed-by: Eric Blake Message-Id: <20210903081358.956267-3-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- meson_options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index a9a9b8f4c6..2c89e79e8b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -120,7 +120,7 @@ option('usb_redir', type : 'feature', value : 'auto', description: 'libusbredir support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') -option('vnc', type : 'feature', value : 'enabled', +option('vnc', type : 'feature', value : 'auto', description: 'VNC server') option('vnc_jpeg', type : 'feature', value : 'auto', description: 'JPEG lossy compression for VNC server') --=20 2.31.1