From patchwork Fri Jun 21 01:42:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11008385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 049CA1398 for ; Fri, 21 Jun 2019 02:02:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E774328908 for ; Fri, 21 Jun 2019 02:02:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB97428939; Fri, 21 Jun 2019 02:02:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.9 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FUZZY_XPILL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 790A028908 for ; Fri, 21 Jun 2019 02:02:40 +0000 (UTC) Received: from localhost ([::1]:54122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8sr-0003pG-QE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Jun 2019 22:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41303) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8a6-0006ff-Ns for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he8a3-0006ga-Rn for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:10 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:52852) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1he8a3-0006M9-2h for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:07 -0400 Received: by mail-wm1-x341.google.com with SMTP id s3so4799244wms.2 for ; Thu, 20 Jun 2019 18:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=46R01TlppRnc8fuF4nJaB/BSCYQl7BxcBYUaCW1Ujrw=; b=MENpUo6m/sczgfCCCcszpwTluR0UbTdC0PihwUoCoqOrXslTn/td3BTF7BkGsSLZub T5TMBs3u4KNfeSGopIs/Nu7/wi1TqfxHjxFxDyNsvL2IYBs0ZmOS3jOtGwJ8oREsq/dr bH4aP3+6WqbskLuUoxECVzvzDE+1b1OogY9sls72TpYFYWkZLIphxcmb8G8FndEZU1Rt T2xEkAMznTnU5mI70+bK3ZnD/+dWAqfttnUK1yHxhZp+2j4qW8fsOn2cZ2zjjh29zwuG Fto8R6VF6GYHF7q9Yxp4zFjCECRUQ2pA5qhh4MZOGbAH8a9BG7NxZQvt55iez+maftO3 642Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=46R01TlppRnc8fuF4nJaB/BSCYQl7BxcBYUaCW1Ujrw=; b=fIUiToMJaT9Z4bCxjLu8GPVaQrN/Eycz/lBJzsrsgIuFt4B+WyGfGbd1/gLhi1pkn6 euqu/dfSN9j5hXFDSt0rD7tHrvV1qc8sNlGkX8vdu3FPmIiTPLAzE/k3F7wbiLUS111+ HmKup+v0REAeXP/NeXt9zaWa9A6uaaJshS9cniZYCwaLzUbt6Ev/HOaEcyarFLJyp78h daEJ2YuMLZtgpIcvnAQ5zk1/sJLygX3l7oH/kAUst+UdVAZ080DiIUxRBjjkJP1WkSVS oc9iqzpVbrZED/NM1dctNNPb8A/4Nezm244GLCly9iZqhwqjSAwkShF0+7cHN3lGC8Kh 3Szg== X-Gm-Message-State: APjAAAWGSZuceH8fg1uwLwXnPLXJdIhoBQdm6yFzfM3CXjC21TRtnFa5 dhGsagH7y69LziAAOinIjGoVOlXD X-Google-Smtp-Source: APXvYqyx2FZeCbmS7/8zGl43YD1+arX4ZLYQwI+I89tAUJEaAdtcgR47EPUUD+IaX7/rDGs6US4vRg== X-Received: by 2002:a1c:b155:: with SMTP id a82mr1440682wmf.35.1561081370758; Thu, 20 Jun 2019 18:42:50 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d1sm1123125wru.41.2019.06.20.18.42.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 18:42:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2019 03:42:23 +0200 Message-Id: <1561081350-3723-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> References: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PULL 18/25] linux-headers: sync with latest KVM headers from Linux 5.2 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: Liran Alon Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Liran Alon Improve the KVM_{GET,SET}_NESTED_STATE structs by detailing the format of VMX nested state data in a struct. In order to avoid changing the ioctl values of KVM_{GET,SET}_NESTED_STATE, there is a need to preserve sizeof(struct kvm_nested_state). This is done by defining the data struct as "data.vmx[0]". It was the most elegant way I found to preserve struct size while still keeping struct readable and easy to maintain. It does have a misfortunate side-effect that now it has to be accessed as "data.vmx[0]" rather than just "data.vmx". Because we are already modifying these structs, I also modified the following: * Define the "format" field values as macros. * Rename vmcs_pa to vmcs12_pa for better readability. Signed-off-by: Liran Alon Reviewed-by: Maran Wilson Message-Id: <20190619162140.133674-7-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini --- linux-headers/asm-x86/kvm.h | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 7a0e64c..6e7dd79 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -383,16 +383,26 @@ struct kvm_sync_regs { #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) #define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) +#define KVM_STATE_NESTED_FORMAT_VMX 0 +#define KVM_STATE_NESTED_FORMAT_SVM 1 + #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 #define KVM_STATE_NESTED_EVMCS 0x00000004 +#define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 + #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 -struct kvm_vmx_nested_state { +struct kvm_vmx_nested_state_data { + __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; + __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; +}; + +struct kvm_vmx_nested_state_hdr { __u64 vmxon_pa; - __u64 vmcs_pa; + __u64 vmcs12_pa; struct { __u16 flags; @@ -401,24 +411,25 @@ struct kvm_vmx_nested_state { /* for KVM_CAP_NESTED_STATE */ struct kvm_nested_state { - /* KVM_STATE_* flags */ __u16 flags; - - /* 0 for VMX, 1 for SVM. */ __u16 format; - - /* 128 for SVM, 128 + VMCS size for VMX. */ __u32 size; union { - /* VMXON, VMCS */ - struct kvm_vmx_nested_state vmx; + struct kvm_vmx_nested_state_hdr vmx; /* Pad the header to 128 bytes. */ __u8 pad[120]; - }; + } hdr; - __u8 data[0]; + /* + * Define data region as 0 bytes to preserve backwards-compatability + * to old definition of kvm_nested_state in order to avoid changing + * KVM_{GET,PUT}_NESTED_STATE ioctl values. + */ + union { + struct kvm_vmx_nested_state_data vmx[0]; + } data; }; #endif /* _ASM_X86_KVM_H */