From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560560064; cv=none; d=zoho.com; s=zohoarc; b=NrvdYFFimINEIyiYWY9HTLuDyn2sU5jkuhqcyOws/j7YVUxFFyeWIgTYvRADU+Tp+UDbeFn2sm/A99b7JYVxiX216pYRb/9PdVWGlZn9g3crj/fEM7AA6/d9lpTQLxn4dX4KkuWHHjcrOEYo0cz/569R6sDLPS80pCe6MTRCbJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560560064; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bYkbASmVjMT2mdNG6FSEH7YudCdKd0aZFiI+nNUNNKM=; b=aewHOkmVl/2Yb4vCtSbuVna4ewmsDGE0TQ+WoJ2N5rsoLA6BshWSnO1uNoMFHIYL1eGfMe8+4gjzum8D1CYIFIMdIy8CCsBjND6g+HQibZzxRzLjkWWDaEVus4otTfuB9P7e/BP1qgucq3FHIcxQ7OzHohMdNu2LNysVlWBBAos= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156056006406181.06793522345356; Fri, 14 Jun 2019 17:54:24 -0700 (PDT) Received: from localhost ([::1]:57876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwxb-0008Nm-1W for importer@patchew.org; Fri, 14 Jun 2019 20:54:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60432) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmd-0000W2-Or for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwmb-0004BD-PU for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:03 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37700) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwmZ-000484-Td for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:00 -0400 Received: by mail-wm1-x343.google.com with SMTP id f17so1351550wme.2 for ; Fri, 14 Jun 2019 17:42:58 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.42.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:42:56 -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 :mime-version:content-transfer-encoding; bh=bYkbASmVjMT2mdNG6FSEH7YudCdKd0aZFiI+nNUNNKM=; b=dxlhyuwG321edrbnaPCe4JWR3RKp1FCJsKWay4G7h9mQPo4SNQ8HauJ21PVW4F9pX/ glWmdDW1fJwtYNQ8qMi6YD5ZSePrEhIu6Vya9uINKmbMERXj/J1mOmA0cDxLCwuMDfe1 48Yhsg4ajAQvazqMn5oELHXV7IxlkU92J9o2lBGHAI6joxcK/HkO/W8z4bQM1ERVNcie vvCnepl5eHQ9UY0PCwZkl3bNROCX4IcLn8prtvzpt/Jwt+7nyT6k1zq6WEkIjJmEFUGl QeaI+OuElgeTRsmrWEqcrpQ8lbbg/C83wducJR2qm0P0d5IrhP+TEpWQSqCngEY1fGy2 fXhA== 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:mime-version:content-transfer-encoding; bh=bYkbASmVjMT2mdNG6FSEH7YudCdKd0aZFiI+nNUNNKM=; b=BvaPPfsRxa3a3Vqyg9yYOd3J2FuyDUmlHn1YDf2o1J3j/oWE1s6RXckn2HhaYGLyil EKpCTrGHz6CqCwP3pfT00SXQNard0jVR137PWQxe543Dq3zbKzTt/FXBFo+V7VfXycbX o0LdFdmK1gjLghS/azlL/Yz47WV3GtlOEQyTueGOb8oQLQIUyMetR4bnkz3OBG3oW0dF +rKmaiJFmhst1P0kF1fB+la87eglvERThmS8yfeXdyM7rKKTvfzDqipL7KEJ+/EPoRUO dBafUJvusKUsjdaHAsUvN9Ej1lyggvxyBcFnIVwGNnkHtRHqu+cy5ELCtcD6ninLUZWG SvUA== X-Gm-Message-State: APjAAAV2Xa9U4uAQUEiiZPOfEujrv3orPEyaiOpCwnmKiVnYtFSghyF6 NfhItgy+CKCTAtSoBO1vJIiolW+7 X-Google-Smtp-Source: APXvYqxE9rPfuKKQom4W6PusArHAn5zNjq+dn5gs5WwVTRXjo7LwYt0azlWgX7Usht+7OaToOpdAOg== X-Received: by 2002:a7b:ca43:: with SMTP id m3mr9957915wml.45.1560559376784; Fri, 14 Jun 2019 17:42:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:50 +0200 Message-Id: <20190615004256.16367-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 1/7] KVM: i386: Use symbolic constant for #DB/#BP exception constants 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 3b29ce5c0d..c8d8196e71 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2994,9 +2994,9 @@ static int kvm_guest_debug_workarounds(X86CPU *cpu) unsigned long reinject_trap =3D 0; =20 if (!kvm_has_vcpu_events()) { - if (env->exception_injected =3D=3D 1) { + if (env->exception_injected =3D=3D EXCP01_DB) { reinject_trap =3D KVM_GUESTDBG_INJECT_DB; - } else if (env->exception_injected =3D=3D 3) { + } else if (env->exception_injected =3D=3D EXCP03_INT3) { reinject_trap =3D KVM_GUESTDBG_INJECT_BP; } env->exception_injected =3D -1; @@ -3508,7 +3508,7 @@ static int kvm_handle_debug(X86CPU *cpu, int ret =3D 0; int n; =20 - if (arch_info->exception =3D=3D 1) { + if (arch_info->exception =3D=3D EXCP01_DB) { if (arch_info->dr6 & (1 << 14)) { if (cs->singlestep_enabled) { ret =3D EXCP_DEBUG; --=20 2.21.0 From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560559642; cv=none; d=zoho.com; s=zohoarc; b=i3ryEPl+I8X4/pzKAUGsp0s6+W+mBvLbI0V6OVmxIwRdYppzh94jGXIj7v4YZ5+YlpNFFOYGhfZ5i42jTlozA89b3VlUPM1uxzH3uWqZdHaF1lZZNYgR1rgTSMMSY+HQ7FFwy184DD0IjGUSvLHOVQNsnU+h0Oiwhfs0UVCHLpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560559642; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Tuj2jcO/BLerGp9WHchtQ73E8BBK3njFpTpGB+i8VjI=; b=djg7gPTeY/J03xzChYh/D0ytwkFzcepIK+ptMroe3PKV/DmYutzR8HRkLdT8EQ+I5fGAQxvvcl2aVGm6EYdpFYZY5PPPGgjNVuxxCFHOTCgTsJvJek4iUPEygKjw8WdnS4JB7HqHS4PsPd83iCQSEbsfarrQFwju3GXC8mUewuw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560559642942806.9425963571929; Fri, 14 Jun 2019 17:47:22 -0700 (PDT) Received: from localhost ([::1]:57814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwqi-0002Lj-11 for importer@patchew.org; Fri, 14 Jun 2019 20:47:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60420) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmc-0000Vr-Dp for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwma-0004Aj-OJ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:01 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35064) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwmZ-00049W-UZ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:00 -0400 Received: by mail-wm1-x343.google.com with SMTP id c6so3877964wml.0 for ; Fri, 14 Jun 2019 17:42:58 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.42.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:42:57 -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 :mime-version:content-transfer-encoding; bh=Tuj2jcO/BLerGp9WHchtQ73E8BBK3njFpTpGB+i8VjI=; b=FfUlWh4NN90smDWXqsZIEUrL80d5krp6TQUPG85yIn2No5UHhYhb4tdc2EEvA64WMw jyAFA0mTXSugllkdFdWVJJM/1rTeWOpG9DxYwvAqYJ9IA6ziX03qT+N4Na+TsaeAPJjh hIHRhncetbUj260Jbe8I/Yf9A1vGWrBvRspy3Xbi8ou/6sNv0VFe8M/keovvFPmKYY/o BeezW0iorndlXyuD51dyhuivGh0eQnVSG7dwtRQcPbjIFhYBQwgPnOheF7ibIY1EkL7w gcTg0nPfxOgDkNE1DziYY9Jnp56oz9xscP5uwpvS3HnJxUQC+BXFBiWu6dLyaj/sYpnM glMg== 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:mime-version:content-transfer-encoding; bh=Tuj2jcO/BLerGp9WHchtQ73E8BBK3njFpTpGB+i8VjI=; b=MogGfL/bUp2OQgZaO0kfsc+rq2Tpw7L8LPa5bJg3BjDr60Lu2jSvEPfSr9vKdB6XKJ KYdQvMmzPalGYqfRqByMG/paNRqoscpbswwt38jLf7bkqmOhUNVUDXtF5mpGOsGsploP 88QipTZehqJUZiXh+bxymsXNqiQpk+kNyqJjRQXKtbp0kQak1bMRwtnij5768MQ/uBeq /3nBY9JJ7wtyLEZ+Hb87MYnGKUDKc4OYjUnUzm53NzIoXuqhDW7Axf7HV3aMo2Y0vcOk us+U6W0mj5GuN4QdzNFcpP2L059iprmRIIHOsQk2LlxkTYR/8WNouzuza+IR6PfewQtP jVpg== X-Gm-Message-State: APjAAAUR2LKYJvOi0r+ha0hhwdTZaTcUJJU4bBGK0iq+6KNtWrBELqqW +I6zApgd22rgaEImxtlUcoo6Wawz X-Google-Smtp-Source: APXvYqxnDfbSIMjtDK6qE3IP4/WjGAGMF/TrvxTtI9EYB8Nr4KbaoV53xwSxcyApa+FcNQgPMu2X0g== X-Received: by 2002:a1c:3c8a:: with SMTP id j132mr9528804wma.172.1560559377625; Fri, 14 Jun 2019 17:42:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:51 +0200 Message-Id: <20190615004256.16367-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 2/7] KVM: i386: Re-inject #DB to guest with updated DR6 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon If userspace (QEMU) debug guest, when #DB is raised in guest and intercepted by KVM, KVM forwards information on #DB to userspace instead of injecting #DB to guest. While doing so, KVM don't update vCPU DR6 but instead report the #DB DR6 value to userspace for further handling. See KVM's handle_exception() DB_VECTOR handler. QEMU handler for this case is kvm_handle_debug(). This handler basically checks if #DB is related to one of user set hardware breakpoints and if not, it re-inject #DB into guest. The re-injection is done by setting env->exception_injected to #DB which will later be passed as events.exception.nr to KVM_SET_VCPU_EVENTS ioctl by kvm_put_vcpu_events(). However, in case userspace re-injects #DB, KVM expects userspace to set vCPU DR6 as reported to userspace when #DB was intercepted! Otherwise, KVM_REQ_EVENT handler will inject #DB with wrong DR6 to guest. Fix this issue by updating vCPU DR6 appropriately when re-inject #DB to guest. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index c8d8196e71..53f95b02a0 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -3546,6 +3546,9 @@ static int kvm_handle_debug(X86CPU *cpu, /* pass to guest */ env->exception_injected =3D arch_info->exception; env->has_error_code =3D 0; + if (arch_info->exception =3D=3D EXCP01_DB) { + env->dr[6] =3D arch_info->dr6; + } } =20 return ret; --=20 2.21.0 From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560560206; cv=none; d=zoho.com; s=zohoarc; b=hm7CMQqvyuRa58NQAA2eLYM3jh77ubF8gQcPXTxTszERbUqDUmCQOY96cUrAJX5O1F9ID8nZ5TnqPfoUy4gu5waMlwUekQyqZ5pWwubAulZ0oMtcV/2fTcBqfeCYaHJJNPvJaZrA+imrqoSzIcN781IhVQW1Nkqp3Pn4aTgsC4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560560206; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+7Xf4ehPVEjmQK/UU3GOZut7M7AHJc9i0ZuuPNjoMyo=; b=HYZypc1H9lcsb9WYbEPRElPJWz43gHXueJa5c5HZZJnkBi/vHJnLwkeJw1hSG72+X+zPJn5AxjLJvrOTYyrrWTzFt9EP8jFbI309GkmkdoPwoMx1wZYpC5EsXvXzWynzLvOkTDKVQnVPXoCMEmn+SRNq9TXUW0GT7q7HYc+oTIk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560560206500260.1574545823769; Fri, 14 Jun 2019 17:56:46 -0700 (PDT) Received: from localhost ([::1]:57892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwzo-0001cn-Hc for importer@patchew.org; Fri, 14 Jun 2019 20:56:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60453) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmf-0000WL-Os for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwmd-0004Ez-Ms for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:05 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwma-0004A8-Na for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:01 -0400 Received: by mail-wr1-x444.google.com with SMTP id x17so4195493wrl.9 for ; Fri, 14 Jun 2019 17:43:00 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.42.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:42:57 -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 :mime-version:content-transfer-encoding; bh=+7Xf4ehPVEjmQK/UU3GOZut7M7AHJc9i0ZuuPNjoMyo=; b=vgGYJCJVn25Rv+9xWKwQV8m6sX/bk6i4/Z9xt2pRkEuyQ6fh9HjYB1UUQFcRhr0tmh a2VFLq3RnWIFea+q+Kxe1Ov6GpK6SnUanGpAErvLeDUJ9zg17ixUblrSQ+OMmvKlyAYx yssvbDU4RAd/hCrj8oarrZjAhpczIQXuNwAgMv13KxISqOuIOUJydtmAQKVXlQ2gezwg LUzbMwWrAUW/MBkJqu+sa/Vlt94Hk2P2nVsyLO7EzCLePMq8qqvR8h1rd45PYzruNOYT fqbj/likylSael6lrcMjDxuhiI+bRgKU+Q+Xo7ky67TGSGLVhwWTljsURpw8tirUNnnX 1EaA== 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:mime-version:content-transfer-encoding; bh=+7Xf4ehPVEjmQK/UU3GOZut7M7AHJc9i0ZuuPNjoMyo=; b=FZE219nXIaKgoKrFGP1FW0WSP+9hZimYae8LeXevoZffz17FiHO03nwiaVz8njn8lK 8dmp+xdNotDWPj+a5E9rB4FOGtzbZ6sNz0pNq4PLO3YWqsf4D8R4CTIybhuHtWHQk6tk /FEXxfZSRNg20TMR2uCqtDbruaPbwSSVran5FsHxZR3JAoAhHJrLB63yOkhqdAhtGw68 +weOP4mcGMBs7xoG/3Zq4E0wpG5QJvQhLQOZFD+cAklLUiK0evydxYigkbG2L9F5XdhJ k1rKzNgB6vDNYhWmuPALAPN5Ko9xtW9e4rf5PYplG+JF8F0UHbJzp2DIk+ifydKnhBXf SXhw== X-Gm-Message-State: APjAAAW55PqsrNRc8/8oTnBKKDICfrdyK2kFn5DOr/XNwyULDhoJndif 2mBoilhO/cYMQvCBoOViys264TU+ X-Google-Smtp-Source: APXvYqzVnKL3q5aALG22650hjD/Q191mAKAlV/sHYILD9JyVaIqUrFs+M+fsvoHHXQ6tEgX4efJpzg== X-Received: by 2002:a05:6000:11cc:: with SMTP id i12mr7369109wrx.243.1560559378696; Fri, 14 Jun 2019 17:42:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:52 +0200 Message-Id: <20190615004256.16367-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH 3/7] KVM: i386: Add support for KVM_CAP_EXCEPTION_PAYLOAD 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon Kernel commit c4f55198c7c2 ("kvm: x86: Introduce KVM_CAP_EXCEPTION_PAYLOAD") introduced a new KVM capability which allows userspace to correctly distinguish between pending and injected exceptions. This distinguish is important in case of nested virtualization scenarios because a L2 pending exception can still be intercepted by the L1 hypervisor while a L2 injected exception cannot. Furthermore, when an exception is attempted to be injected by QEMU, QEMU should specify the exception payload (CR2 in case of #PF or DR6 in case of #DB) instead of having the payload already delivered in the respective vCPU register. Because in case exception is injected to L2 guest and is intercepted by L1 hypervisor, then payload needs to be reported to L1 intercept (VMExit handler) while still preserving respective vCPU register unchanged. This commit adds support for QEMU to properly utilise this new KVM capability (KVM_CAP_EXCEPTION_PAYLOAD). Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 10 ++--- target/i386/cpu.h | 13 +++++- target/i386/hvf/hvf.c | 10 +++-- target/i386/hvf/x86hvf.c | 4 +- target/i386/kvm.c | 95 +++++++++++++++++++++++++++++++++------- target/i386/machine.c | 61 +++++++++++++++++++++++++- 6 files changed, 163 insertions(+), 30 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c1ab86d63e..4e19969111 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4777,7 +4777,9 @@ static void x86_cpu_reset(CPUState *s) memset(env->mtrr_fixed, 0, sizeof(env->mtrr_fixed)); =20 env->interrupt_injected =3D -1; - env->exception_injected =3D -1; + env->exception_nr =3D -1; + env->exception_pending =3D 0; + env->exception_injected =3D 0; env->nmi_injected =3D false; #if !defined(CONFIG_USER_ONLY) /* We hard-wire the BSP to the first CPU. */ @@ -5173,12 +5175,6 @@ static int x86_cpu_filter_features(X86CPU *cpu) return rv; } =20 -#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 =3D=3D CPUID_VENDOR_INTEL_= 1 && \ - (env)->cpuid_vendor2 =3D=3D CPUID_VENDOR_INTEL_= 2 && \ - (env)->cpuid_vendor3 =3D=3D CPUID_VENDOR_INTEL_= 3) -#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 =3D=3D CPUID_VENDOR_AMD_1 &&= \ - (env)->cpuid_vendor2 =3D=3D CPUID_VENDOR_AMD_2 &&= \ - (env)->cpuid_vendor3 =3D=3D CPUID_VENDOR_AMD_3) static void x86_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs =3D CPU(dev); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index bd06523a53..bbeb7a9521 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -729,6 +729,13 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; =20 #define CPUID_VENDOR_HYGON "HygonGenuine" =20 +#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 =3D=3D CPUID_VENDOR_INTEL_= 1 && \ + (env)->cpuid_vendor2 =3D=3D CPUID_VENDOR_INTEL_= 2 && \ + (env)->cpuid_vendor3 =3D=3D CPUID_VENDOR_INTEL_= 3) +#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 =3D=3D CPUID_VENDOR_AMD_1 &&= \ + (env)->cpuid_vendor2 =3D=3D CPUID_VENDOR_AMD_2 &&= \ + (env)->cpuid_vendor3 =3D=3D CPUID_VENDOR_AMD_3) + #define CPUID_MWAIT_IBE (1U << 1) /* Interrupts can exit capability */ #define CPUID_MWAIT_EMX (1U << 0) /* enumeration supported */ =20 @@ -1332,10 +1339,14 @@ typedef struct CPUX86State { =20 /* For KVM */ uint32_t mp_state; - int32_t exception_injected; + int32_t exception_nr; int32_t interrupt_injected; uint8_t soft_interrupt; + uint8_t exception_pending; + uint8_t exception_injected; uint8_t has_error_code; + uint8_t exception_has_payload; + uint64_t exception_payload; uint32_t ins_len; uint32_t sipi_vector; bool tsc_valid; diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 2751c8125c..dc4bb63536 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -605,7 +605,9 @@ static void hvf_store_events(CPUState *cpu, uint32_t in= s_len, uint64_t idtvec_in X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; =20 - env->exception_injected =3D -1; + env->exception_nr =3D -1; + env->exception_pending =3D 0; + env->exception_injected =3D 0; env->interrupt_injected =3D -1; env->nmi_injected =3D false; if (idtvec_info & VMCS_IDT_VEC_VALID) { @@ -619,7 +621,8 @@ static void hvf_store_events(CPUState *cpu, uint32_t in= s_len, uint64_t idtvec_in break; case VMCS_IDT_VEC_HWEXCEPTION: case VMCS_IDT_VEC_SWEXCEPTION: - env->exception_injected =3D idtvec_info & VMCS_IDT_VEC_VECNUM; + env->exception_nr =3D idtvec_info & VMCS_IDT_VEC_VECNUM; + env->exception_injected =3D 1; break; case VMCS_IDT_VEC_PRIV_SWEXCEPTION: default: @@ -912,7 +915,8 @@ int hvf_vcpu_exec(CPUState *cpu) macvm_set_rip(cpu, rip + ins_len); break; case VMX_REASON_VMCALL: - env->exception_injected =3D EXCP0D_GPF; + env->exception_nr =3D EXCP0D_GPF; + env->exception_injected =3D 1; env->has_error_code =3D true; env->error_code =3D 0; break; diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index df8e946fbc..e0ea02d631 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -362,8 +362,8 @@ bool hvf_inject_interrupts(CPUState *cpu_state) if (env->interrupt_injected !=3D -1) { vector =3D env->interrupt_injected; intr_type =3D VMCS_INTR_T_SWINTR; - } else if (env->exception_injected !=3D -1) { - vector =3D env->exception_injected; + } else if (env->exception_nr !=3D -1) { + vector =3D env->exception_nr; if (vector =3D=3D EXCP03_INT3 || vector =3D=3D EXCP04_INTO) { intr_type =3D VMCS_INTR_T_SWEXCEPTION; } else { diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 53f95b02a0..dca76830ec 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -104,6 +104,7 @@ static uint32_t num_architectural_pmu_fixed_counters; static int has_xsave; static int has_xcrs; static int has_pit_state2; +static int has_exception_payload; =20 static bool has_msr_mcg_ext_ctl; =20 @@ -584,15 +585,51 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) /* Hope we are lucky for AO MCE */ } =20 +static void kvm_reset_exception(CPUX86State *env) +{ + env->exception_nr =3D -1; + env->exception_pending =3D 0; + env->exception_injected =3D 0; +} + +static void kvm_queue_exception(CPUX86State *env, + int32_t exception_nr, + uint8_t exception_has_payload, + uint64_t exception_payload) +{ + assert(env->exception_nr =3D=3D -1); + assert(!env->exception_pending); + assert(!env->exception_injected); + + env->exception_nr =3D exception_nr; + + if (has_exception_payload) { + env->exception_pending =3D 1; + + env->exception_has_payload =3D exception_has_payload; + env->exception_payload =3D exception_payload; + } else { + env->exception_injected =3D 1; + + if (exception_has_payload) { + if (exception_nr =3D=3D EXCP01_DB) { + env->dr[6] =3D exception_payload; + } else if (exception_nr =3D=3D EXCP0E_PAGE) { + env->cr[2] =3D exception_payload; + } + } + } +} + static int kvm_inject_mce_oldstyle(X86CPU *cpu) { CPUX86State *env =3D &cpu->env; =20 - if (!kvm_has_vcpu_events() && env->exception_injected =3D=3D EXCP12_MC= HK) { + if (!kvm_has_vcpu_events() && env->exception_nr =3D=3D EXCP12_MCHK) { unsigned int bank, bank_num =3D env->mcg_cap & 0xff; struct kvm_x86_mce mce; =20 - env->exception_injected =3D -1; + kvm_reset_exception(env); =20 /* * There must be at least one bank in use if an MCE is pending. @@ -1573,6 +1610,16 @@ int kvm_arch_init(MachineState *ms, KVMState *s) =20 hv_vpindex_settable =3D kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX= ); =20 + has_exception_payload =3D kvm_check_extension(s, KVM_CAP_EXCEPTION_PAY= LOAD); + if (has_exception_payload) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_EXCEPTION_PAYLOAD, 0, true); + if (ret < 0) { + error_report("kvm: Failed to enable exception payload cap: %s", + strerror(-ret)); + return ret; + } + } + ret =3D kvm_get_supported_msrs(s); if (ret < 0) { return ret; @@ -2877,8 +2924,16 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int leve= l) return 0; } =20 - events.exception.injected =3D (env->exception_injected >=3D 0); - events.exception.nr =3D env->exception_injected; + events.flags =3D 0; + + if (has_exception_payload) { + events.flags |=3D KVM_VCPUEVENT_VALID_PAYLOAD; + events.exception.pending =3D env->exception_pending; + events.exception_has_payload =3D env->exception_has_payload; + events.exception_payload =3D env->exception_payload; + } + events.exception.nr =3D env->exception_nr; + events.exception.injected =3D env->exception_injected; events.exception.has_error_code =3D env->has_error_code; events.exception.error_code =3D env->error_code; =20 @@ -2891,7 +2946,6 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level) events.nmi.masked =3D !!(env->hflags2 & HF2_NMI_MASK); =20 events.sipi_vector =3D env->sipi_vector; - events.flags =3D 0; =20 if (has_msr_smbase) { events.smi.smm =3D !!(env->hflags & HF_SMM_MASK); @@ -2941,8 +2995,19 @@ static int kvm_get_vcpu_events(X86CPU *cpu) if (ret < 0) { return ret; } - env->exception_injected =3D - events.exception.injected ? events.exception.nr : -1; + + if (events.flags & KVM_VCPUEVENT_VALID_PAYLOAD) { + env->exception_pending =3D events.exception.pending; + env->exception_has_payload =3D events.exception_has_payload; + env->exception_payload =3D events.exception_payload; + } else { + env->exception_pending =3D 0; + env->exception_has_payload =3D false; + } + env->exception_injected =3D events.exception.injected; + env->exception_nr =3D + (env->exception_pending || env->exception_injected) ? + events.exception.nr : -1; env->has_error_code =3D events.exception.has_error_code; env->error_code =3D events.exception.error_code; =20 @@ -2994,12 +3059,12 @@ static int kvm_guest_debug_workarounds(X86CPU *cpu) unsigned long reinject_trap =3D 0; =20 if (!kvm_has_vcpu_events()) { - if (env->exception_injected =3D=3D EXCP01_DB) { + if (env->exception_nr =3D=3D EXCP01_DB) { reinject_trap =3D KVM_GUESTDBG_INJECT_DB; } else if (env->exception_injected =3D=3D EXCP03_INT3) { reinject_trap =3D KVM_GUESTDBG_INJECT_BP; } - env->exception_injected =3D -1; + kvm_reset_exception(env); } =20 /* @@ -3320,13 +3385,13 @@ int kvm_arch_process_async_events(CPUState *cs) =20 kvm_cpu_synchronize_state(cs); =20 - if (env->exception_injected =3D=3D EXCP08_DBLE) { + if (env->exception_nr =3D=3D EXCP08_DBLE) { /* this means triple fault */ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); cs->exit_request =3D 1; return 0; } - env->exception_injected =3D EXCP12_MCHK; + kvm_queue_exception(env, EXCP12_MCHK, 0, 0); env->has_error_code =3D 0; =20 cs->halted =3D 0; @@ -3541,14 +3606,12 @@ static int kvm_handle_debug(X86CPU *cpu, } if (ret =3D=3D 0) { cpu_synchronize_state(cs); - assert(env->exception_injected =3D=3D -1); + assert(env->exception_nr =3D=3D -1); =20 /* pass to guest */ - env->exception_injected =3D arch_info->exception; + kvm_queue_exception(env, arch_info->exception, + EXCP01_DB, arch_info->dr6); env->has_error_code =3D 0; - if (arch_info->exception =3D=3D EXCP01_DB) { - env->dr[6] =3D arch_info->dr6; - } } =20 return ret; diff --git a/target/i386/machine.c b/target/i386/machine.c index 225b5d433b..41460be54b 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -199,6 +199,21 @@ static const VMStateDescription vmstate_fpreg =3D { } }; =20 +static bool is_vmx_enabled(CPUX86State *env) +{ + return (IS_INTEL_CPU(env) && (env->cr[4] & CR4_VMXE_MASK)); +} + +static bool is_svm_enabled(CPUX86State *env) +{ + return (IS_AMD_CPU(env) && (env->efer & MSR_EFER_SVME)); +} + +static bool is_nested_virt_enabled(CPUX86State *env) +{ + return (is_vmx_enabled(env) || is_svm_enabled(env)); +} + static int cpu_pre_save(void *opaque) { X86CPU *cpu =3D opaque; @@ -278,6 +293,23 @@ static int cpu_post_load(void *opaque, int version_id) env->hflags &=3D ~HF_CPL_MASK; env->hflags |=3D (env->segs[R_SS].flags >> DESC_DPL_SHIFT) & HF_CPL_MA= SK; =20 + /* + * There are cases that we can get valid exception_nr with both + * exception_pending and exception_clear being cleared. This can happe= n in + * one of the following scenarios: + * 1) Source is older QEMU without KVM_CAP_EXCEPTION_PAYLOAD support. + * 2) Source is running on kernel without KVM_CAP_EXCEPTION_PAYLOAD su= pport. + * 3) "cpu/exception_info" subsection not sent because there is no exc= eption + * pending or guest wasn't running L2. + * + * In those cases, we can just deduce that a valid exception_nr means + * we can treat the exception as already injected. + */ + if ((env->exception_nr !=3D -1) && + !env->exception_pending && !env->exception_injected) { + env->exception_injected =3D 1; + } + env->fpstt =3D (env->fpus_vmstate >> 11) & 7; env->fpus =3D env->fpus_vmstate & ~0x3800; env->fptag_vmstate ^=3D 0xff; @@ -323,6 +355,32 @@ static bool steal_time_msr_needed(void *opaque) return cpu->env.steal_time_msr !=3D 0; } =20 +static bool exception_info_needed(void *opaque) +{ + X86CPU *cpu =3D opaque; + + /* + * Differenting between pending and injected exceptions + * is only important when running L2. + */ + return (cpu->env.exception_pending && + is_nested_virt_enabled(&cpu->env)); +} + +static const VMStateDescription vmstate_exception_info =3D { + .name =3D "cpu/exception_info", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D exception_info_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(env.exception_pending, X86CPU), + VMSTATE_UINT8(env.exception_injected, X86CPU), + VMSTATE_UINT8(env.exception_has_payload, X86CPU), + VMSTATE_UINT64(env.exception_payload, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_steal_time_msr =3D { .name =3D "cpu/steal_time_msr", .version_id =3D 1, @@ -1035,7 +1093,7 @@ VMStateDescription vmstate_x86_cpu =3D { VMSTATE_INT32(env.interrupt_injected, X86CPU), VMSTATE_UINT32(env.mp_state, X86CPU), VMSTATE_UINT64(env.tsc, X86CPU), - VMSTATE_INT32(env.exception_injected, X86CPU), + VMSTATE_INT32(env.exception_nr, X86CPU), VMSTATE_UINT8(env.soft_interrupt, X86CPU), VMSTATE_UINT8(env.nmi_injected, X86CPU), VMSTATE_UINT8(env.nmi_pending, X86CPU), @@ -1059,6 +1117,7 @@ VMStateDescription vmstate_x86_cpu =3D { /* The above list is not sorted /wrt version numbers, watch out! */ }, .subsections =3D (const VMStateDescription*[]) { + &vmstate_exception_info, &vmstate_async_pf_msr, &vmstate_pv_eoi_msr, &vmstate_steal_time_msr, --=20 2.21.0 From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560559709; cv=none; d=zoho.com; s=zohoarc; b=LE6MlEWmR/Y5VQEduSKW7ea9/urd8HJ38pCuyUR1l+rag+QfpNJiPXLDuSoZN4aRfCRw+yCGSGvbqRNGVMX7pRcvxS/MN53T+6a1bQxirYcCbJ1UITkliEfknA/3nQeOc1KA0tU3Zwz0Y7rquDJbh6D55rV9PSxY7jBZ7X9AxyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560559709; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3B/bfXURZHaVjJAIBJ0jUA1Z41SYUF9H91mCqN9VRIY=; b=FOCnlomIIWc3O7H1wOIk5HcXGY3Wta5Sb8kfZJqV6y5lHf+4gvansowx7eut+9TaabyQBkNkLatLDThF7ozLpKfAAQ48eT4oBf32jXMkhu6CjPMQ9E+bOXL3dvtm/DedWBr1ogE4r+GuNYLU+C9rZZAANa80aSDdM+KhZFTVwno= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15605597095371014.8680685769367; Fri, 14 Jun 2019 17:48:29 -0700 (PDT) Received: from localhost ([::1]:57826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwrn-0002X7-Cr for importer@patchew.org; Fri, 14 Jun 2019 20:48:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60498) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmh-0000Wm-L4 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwmf-0004ID-Nd for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:07 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:40600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwmd-0004AS-Oj for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:05 -0400 Received: by mail-wr1-x443.google.com with SMTP id p11so4215310wre.7 for ; Fri, 14 Jun 2019 17:43:00 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.42.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:42:59 -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 :mime-version:content-transfer-encoding; bh=3B/bfXURZHaVjJAIBJ0jUA1Z41SYUF9H91mCqN9VRIY=; b=vPtSkI++evlUCPvTkjuIHRSyGK1jxL0NWT/PY3lTrb51hETdV2pNFBErF1J08KZUtV Rmet41kRpC+/LEn+gQDDHsh0EudT57EUZFkVsfJPeL+oQwvx6jvKDc7HHFPzgdEVcrCA Q7xx9LolLDiH0+4dEaCsoEoVHveP7wd4ZkJhgy/XzdKoLArTCsdaF8Chc3v+rtDVgn4s lGuMv9BeKxInqrS2kR7rJiL7Td776lut0+nrbktJaRN/mCpPMOoQ9rnLjFwswgs8F69V SgYDproCZfl70RUdS8UBoKTAPhhPEueapLUdZq9ZNgehJ8+H6RLrHvLDJCMzqcKqkxEQ 7z/w== 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:mime-version:content-transfer-encoding; bh=3B/bfXURZHaVjJAIBJ0jUA1Z41SYUF9H91mCqN9VRIY=; b=OHHt3a9cwTsDvrvr4gl15KEh4iLKyPX+3geqyxE5f8rdvXX19LI7ii3NNQx15RYiDf yyW/UF/IwyuKnfFuUgDXImFA1S5Ka+HehmM91sTJ/xVZKDNrcrDjckuOjlVG6EQr4F7g 29AInQnsgQgYigq8dHYGk0QdX8mvt0HBAch71Na7Gs5S9lAkYBTG8OYl28ZS+3KuOg7u Rf177RFtvcuI1raiQEyqQN6NAuiFrxI2Q2ENRN4tBClm0yBvhTmC8/rN43z6p0jGxROW g5/JLDPhSb7jHySGHYyd+n1j/Jp9UDgPzV7i1PdtwE5CzyFbXeV3OkpgKWLb+/TNElhM VRuw== X-Gm-Message-State: APjAAAUc6dK+JwpE5/BOmUe2xTZ0wYPFgvJJoDnjFhcy8DES8vIsPznv I6lWT28gYy/HmsOAyFWyWfLIvlvr X-Google-Smtp-Source: APXvYqwW87LgiSWNqqIhdgWANSe8mA/vzRL0BHQ+eI20z1LFZIjKmb8ia+yWS2BxGhTMcMEIaMhXxw== X-Received: by 2002:adf:e7ca:: with SMTP id e10mr5032965wrn.281.1560559379627; Fri, 14 Jun 2019 17:42:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:53 +0200 Message-Id: <20190615004256.16367-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 4/7] linux-headers: import improved definition of KVM_GET/SET_NESTED_STATE structs 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch improves the KVM_GET/SET_NESTED_STATE structs by detailing the format of VMX nested state in a struct. The VMX nested state is accessible through struct kvm_vmx_nested_state though, to avoid changing the size of the structs, it has to be accessed as "vmx.data[0]" rather than just "vmx.data". Also, the values of the "format" field are defined as macros. This patch should be sent to Linus very shortly. Signed-off-by: Paolo Bonzini --- linux-headers/asm-x86/kvm.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 7a0e64ccd6..06b8727a3b 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -383,6 +383,9 @@ struct kvm_sync_regs { #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) #define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) =20 +#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 @@ -390,6 +393,11 @@ struct kvm_sync_regs { #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 =20 +struct kvm_vmx_nested_state_data { + __u8 vmcs12[0x1000]; + __u8 shadow_vmcs12[0x1000]; +}; + struct kvm_vmx_nested_state { __u64 vmxon_pa; __u64 vmcs_pa; @@ -397,6 +405,9 @@ struct kvm_vmx_nested_state { struct { __u16 flags; } smm; + + __u8 pad[120 - 18]; + struct kvm_vmx_nested_state_data data[0]; }; =20 /* for KVM_CAP_NESTED_STATE */ --=20 2.21.0 From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560559680; cv=none; d=zoho.com; s=zohoarc; b=HwhXvTBarDMlmdpDqLlGAMksibLiF+udBm+YBGGbDRtuMvxirSZ4cLI0Sg/WKO/WRFvY3JrHDmInjp4k9Scfq+3sS74z6NqmhRzVQFSOaSAeVwHN5WscltuOGwUUItXmZG4hHLFD+iyZZc+miRRN0vNBIkiD8oTQdTofEjKpcBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560559680; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bLutnU/dkTXvJoiW5spoJToFM65YGUTnPwiUoNTJhIg=; b=jIc54VUNI6FYgOUTntziDjx3a30bCYtcifx56LxZOnXlSYjCy7L/59EPvcEgV9kXhKf+BIHI5MCE3Rijuk0lxOmY+aBbRcI4PPZq8CHkOe6tV0bBRr2gt8fJ95mBSGXc/hvIYpP1JYSphKykfpSjgOII2D+dUzlIzQtcbZZjkQE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560559680166924.4396627629657; Fri, 14 Jun 2019 17:48:00 -0700 (PDT) Received: from localhost ([::1]:57822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwrK-0002R4-4l for importer@patchew.org; Fri, 14 Jun 2019 20:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60481) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmg-0000WU-O6 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwmf-0004IH-O6 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:06 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:50668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwmd-0004Aw-PO for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:05 -0400 Received: by mail-wm1-x333.google.com with SMTP id c66so3986662wmf.0 for ; Fri, 14 Jun 2019 17:43:01 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.42.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:42:59 -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 :mime-version:content-transfer-encoding; bh=bLutnU/dkTXvJoiW5spoJToFM65YGUTnPwiUoNTJhIg=; b=uYAOQmayP9gskY4eyV9vuYglowPT/SLAH2JizBZ5vxTL6QYgXz2fZ6zF1sNKbHMaJQ mDijknCFByVxMl+CwqZEOBGvDU6KRRK4QY7/qg0mWX40O5a8ldx7vrBX4x4TKi05sG6Z SAbwwH5ELq9s4JjK7Gu6t6RykhJbtHArmIiOr4e5WraILdqfiIjd/gMcmuljy9jNP00+ R3oTXbmVqWhSDwo14ma7N9jRT5YtAxub1Q0zzXx5uurxg4JYOgkmoMw1101UgnGPx7yI 5T4f+hY4o9SGvdZnTA4ETVjFFzmrF+/33nqCfRkWZRhKBR30fI8YvhoOk9AVwcJLjFKD o3yg== 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:mime-version:content-transfer-encoding; bh=bLutnU/dkTXvJoiW5spoJToFM65YGUTnPwiUoNTJhIg=; b=C9NofMYaj0nJRDdkbfysZC5Ovxi4i6jLrnxaBGFbE/la2DYu+JMkZEfb99r891kJ+a pI0Yk3MTjd5AVrfzzv/U0jjkQFnFcZprHNWJChRkDvU7xpkkUaJTNrAhAzKbF5puB8dg JEL3YGPL/3/+e4R5rotTwR4dDhWhNomrXrFSiHcVwDgIFR5f42oc6CoOyiKR+ibbZd3G L78VNOeRHxOYqwLGHoDdd+ALCXIET0Gp61/F8KWtmAX0sH7uSOikSwR5/yKoSidMFMJf kPlnX6vA+1U/JUL227+1YmetFB1TCSv+9zcFAnClzD76GrvW2/XTpn/Caw5NRYxkSm8v Sixg== X-Gm-Message-State: APjAAAX1gMiuw3tt7zMyI4l8+h4cxwwBbjZM7l4Qs1DSwHGs7cHEjIB+ na0EghTKDUlk2ALz1mn22kLaG8Sx X-Google-Smtp-Source: APXvYqwdaIXDIBheJjiutUHDc7mPJVLxj8xPFIrYQjdURZHxjyKfMFCJkihMNBMcoelekAYc/VBZUg== X-Received: by 2002:a1c:4041:: with SMTP id n62mr10071538wma.100.1560559380520; Fri, 14 Jun 2019 17:43:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:54 +0200 Message-Id: <20190615004256.16367-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PATCH 5/7] vmstate: Add support for kernel integer types 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini --- include/migration/vmstate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 9224370ed5..a85424fb04 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -797,6 +797,15 @@ extern const VMStateInfo vmstate_info_qtailq; #define VMSTATE_UINT64_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) =20 +#define VMSTATE_U8_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, __u8) +#define VMSTATE_U16_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, __u16) +#define VMSTATE_U32_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, __u32) +#define VMSTATE_U64_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, __u64) + #define VMSTATE_BOOL(_f, _s) \ VMSTATE_BOOL_V(_f, _s, 0) =20 @@ -818,6 +827,15 @@ extern const VMStateInfo vmstate_info_qtailq; #define VMSTATE_UINT64(_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) =20 +#define VMSTATE_U8(_f, _s) \ + VMSTATE_U8_V(_f, _s, 0) +#define VMSTATE_U16(_f, _s) \ + VMSTATE_U16_V(_f, _s, 0) +#define VMSTATE_U32(_f, _s) \ + VMSTATE_U32_V(_f, _s, 0) +#define VMSTATE_U64(_f, _s) \ + VMSTATE_U64_V(_f, _s, 0) + #define VMSTATE_UINT8_EQUAL(_f, _s, _err_hint) \ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ vmstate_info_uint8_equal, uint8_t, _err_hint) --=20 2.21.0 From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560559709; cv=none; d=zoho.com; s=zohoarc; b=R4v2lANFqq0a32b3MYJkhu7Hk2k5F3q+mgZiLd+4VsWZJI1XDx/VNqDKcFnOLXFv3T7Q/FSb+EpRdIJMKnP6CjA4TbhmdznkJzFB2KOfZpQjzbtcGFsKOf0Z67eBONr/pZpZVT9GFxYUB8WKNyehgC8wcUI+jwYfqM/yzr4HkFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560559709; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VNC9SQjCObEeskesampTTSXTeg4IPSZcyOaU7eslfdw=; b=k8yIxuinPHdaIn+odsXiZdbtqycOScLAQsedPaT3IJ3FDhiN+sRjCZ2RP/5+R1hRRiw7VCzrFlKsCjyTrAvYsg8VWqwWoOyXyPa8zF8tCIenwWZPiu1xOKyrGLhUHFRHAfVwd6vFkZwPfAI3AdE/VptGyBs1aW3IS6mv19VD3jM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560559709778130.17751251696347; Fri, 14 Jun 2019 17:48:29 -0700 (PDT) Received: from localhost ([::1]:57824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwrn-0002Vq-O9 for importer@patchew.org; Fri, 14 Jun 2019 20:48:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60497) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmh-0000Wl-LD for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwmf-0004Hq-LK for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:07 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwmd-0004CD-ME for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:05 -0400 Received: by mail-wm1-x343.google.com with SMTP id g135so3953230wme.4 for ; Fri, 14 Jun 2019 17:43:02 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.43.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:43:00 -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 :mime-version:content-transfer-encoding; bh=VNC9SQjCObEeskesampTTSXTeg4IPSZcyOaU7eslfdw=; b=WGtQ0JX+Pi7tFUdPpGx+Tv8uoFYnuQAnMclcZ2UT5gFcgbeqnNvd4mkoN2R58v4/2x 8UGNQjo1RAyP6OcT/C1PJEoqbmqKMdiL2mBDthngRPTO8VDUOXuufcNEF4Zk2CUIzsxq /Z1eFCjXXgSHHizfxxaV9Q8xadAqmtMpaGdwjibs/BWDGCZ6XSM/tLQnuU7N8i+ZO9p3 HGIWJG83nVPipdLbu1+v3hy1OjgOGizfsZBhs0DioVxjk2+Zg0qncDgMef8afg9uMZsw AQXEn13MmFw41ssjkaEA8DK2Ryeaz6pHkYBDiYsyym0Y4MMEJakGeoL9i9tBXghFb+jP RA0w== 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:mime-version:content-transfer-encoding; bh=VNC9SQjCObEeskesampTTSXTeg4IPSZcyOaU7eslfdw=; b=Hq6JO1IZ7XWSkO00jnIpkx5IOejuo21Rnyxn0O7VU6Lt/dSzUnm2j+lOHY8jDsHTAi k5DdPBtYBmT7CCT+c0RETXAet/vduREVam7pG1ZnygkllBb9W+EIhTtmY4xPfHExgyvO C70E4jeaz1DQvuAq6gAIsR4HTQm4mxXAunFLZHaH5hDmSnGfVNhGqBG4qui8HL2oDoA8 Mk2a9Y7K4zsN3QP9MLL3oxnal6+vn4cYRdgJwccCCOJW+Rj7P2Ed/n1/e6FrUgb1U4S6 15j2OezExByn+ffiLsDwCHljze80l5ZARqwI32P/DqKxJrmMcHAWC3eUpkcoWe5nmc6Y cHDw== X-Gm-Message-State: APjAAAVuQhoU+ecYibLN7miTaCmftwOY2vew67YRJj6VY++w7I5jQS4B iIOUUgQCyoYM7Dr2CuSxNpH6CIPv X-Google-Smtp-Source: APXvYqw9VXuvb35QNjxZWcVLuBw/HI2qe94FVfsU1Cxi8I0gkoI9w1dJjlswZ8AGvD7iSZPiOzF3zA== X-Received: by 2002:a1c:a952:: with SMTP id s79mr10354012wme.28.1560559381300; Fri, 14 Jun 2019 17:43:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:55 +0200 Message-Id: <20190615004256.16367-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 6/7] KVM: i386: Add support for save and restore nested state 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon Kernel commit 8fcc4b5923af ("kvm: nVMX: Introduce KVM_CAP_NESTED_STATE") introduced new IOCTLs to extract and restore KVM internal state used to run a VM that is in VMX operation. Utilize these IOCTLs to add support of migration of VMs which are running nested hypervisors. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon [Simplified subsection needed functions and computation of kvm_min_nested_state_len(); adjusted for upstream kernel field names; fixed !CONFIG_KVM compilation. - Paolo] Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 8 ++ include/sysemu/kvm.h | 1 + target/i386/cpu.h | 3 + target/i386/kvm.c | 52 ++++++++++++ target/i386/machine.c | 182 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 246 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e4ac3386cb..e1c6c067e8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -88,6 +88,7 @@ struct KVMState #ifdef KVM_CAP_SET_GUEST_DEBUG QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; #endif + uint32_t max_nested_state_len; int many_ioeventfds; int intx_set_mask; bool sync_mmu; @@ -1677,6 +1678,8 @@ static int kvm_init(MachineState *ms) s->debugregs =3D kvm_check_extension(s, KVM_CAP_DEBUGREGS); #endif =20 + s->max_nested_state_len =3D kvm_check_extension(s, KVM_CAP_NESTED_STAT= E); + #ifdef KVM_CAP_IRQ_ROUTING kvm_direct_msi_allowed =3D (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI)= > 0); #endif @@ -2244,6 +2247,11 @@ int kvm_has_debugregs(void) return kvm_state->debugregs; } =20 +uint32_t kvm_max_nested_state_length(void) +{ + return kvm_state->max_nested_state_len; +} + int kvm_has_many_ioeventfds(void) { if (!kvm_enabled()) { diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index a6d1cd190f..5eb79b594c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -210,6 +210,7 @@ bool kvm_has_sync_mmu(void); int kvm_has_vcpu_events(void); int kvm_has_robust_singlestep(void); int kvm_has_debugregs(void); +uint32_t kvm_max_nested_state_length(void); int kvm_has_pit_state2(void); int kvm_has_many_ioeventfds(void); int kvm_has_gsi_routing(void); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index bbeb7a9521..550d397807 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1355,6 +1355,9 @@ typedef struct CPUX86State { #if defined(CONFIG_KVM) || defined(CONFIG_HVF) void *xsave_buf; #endif +#if defined(CONFIG_KVM) + struct kvm_nested_state *nested_state; +#endif #if defined(CONFIG_HVF) HVFX86EmulatorState *hvf_emul; #endif diff --git a/target/i386/kvm.c b/target/i386/kvm.c index dca76830ec..d48fafa22b 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -968,6 +968,7 @@ int kvm_arch_init_vcpu(CPUState *cs) struct kvm_cpuid_entry2 *c; uint32_t signature[3]; int kvm_base =3D KVM_CPUID_SIGNATURE; + uint32_t nested_state_len; int r; Error *local_err =3D NULL; =20 @@ -1368,6 +1369,13 @@ int kvm_arch_init_vcpu(CPUState *cs) if (has_xsave) { env->xsave_buf =3D qemu_memalign(4096, sizeof(struct kvm_xsave)); } + + nested_state_len =3D kvm_max_nested_state_length(); + if (nested_state_len > 0) { + assert(nested_state_len >=3D offsetof(struct kvm_nested_state, dat= a)); + env->nested_state =3D g_malloc0(nested_state_len); + } + cpu->kvm_msr_buf =3D g_malloc0(MSR_BUF_SIZE); =20 if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_RDTSCP)) { @@ -3125,6 +3133,41 @@ static int kvm_get_debugregs(X86CPU *cpu) return 0; } =20 +static int kvm_put_nested_state(X86CPU *cpu) +{ + CPUX86State *env =3D &cpu->env; + uint32_t nested_state_len =3D kvm_max_nested_state_length(); + + if (nested_state_len =3D=3D 0) { + return 0; + } + + assert(env->nested_state->size <=3D nested_state_len); + return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_NESTED_STATE, env->nested_stat= e); +} + +static int kvm_get_nested_state(X86CPU *cpu) +{ + CPUX86State *env =3D &cpu->env; + uint32_t nested_state_len =3D kvm_max_nested_state_length(); + + if (nested_state_len =3D=3D 0) { + return 0; + } + + /* + * It is possible that migration restored a smaller size into + * nested_state->size than what our kernel supports. + * We preserve migration origin nested_state->size for + * the call to KVM_SET_NESTED_STATE but wish that our next call + * to KVM_GET_NESTED_STATE will use the maximum size supported by + * the kernel we're running on. + */ + env->nested_state->size =3D nested_state_len; + + return kvm_vcpu_ioctl(CPU(cpu), KVM_GET_NESTED_STATE, env->nested_stat= e); +} + int kvm_arch_put_registers(CPUState *cpu, int level) { X86CPU *x86_cpu =3D X86_CPU(cpu); @@ -3132,6 +3175,11 @@ int kvm_arch_put_registers(CPUState *cpu, int level) =20 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); =20 + ret =3D kvm_put_nested_state(x86_cpu); + if (ret < 0) { + return ret; + } + if (level >=3D KVM_PUT_RESET_STATE) { ret =3D kvm_put_msr_feature_control(x86_cpu); if (ret < 0) { @@ -3247,6 +3295,10 @@ int kvm_arch_get_registers(CPUState *cs) if (ret < 0) { goto out; } + ret =3D kvm_get_nested_state(cpu); + if (ret < 0) { + goto out; + } ret =3D 0; out: cpu_sync_bndcs_hflags(&cpu->env); diff --git a/target/i386/machine.c b/target/i386/machine.c index 41460be54b..45dbae6054 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -246,6 +246,15 @@ static int cpu_pre_save(void *opaque) env->segs[R_SS].flags &=3D ~(env->segs[R_SS].flags & DESC_DPL_MASK= ); } =20 +#ifdef CONFIG_KVM + /* Verify we have nested virtualization state from kernel if required = */ + if (is_nested_virt_enabled(env) && !env->nested_state) { + error_report("Guest enabled nested virtualization but kernel " + "do not support saving nested state"); + return -EINVAL; + } +#endif + return 0; } =20 @@ -909,6 +918,176 @@ static const VMStateDescription vmstate_tsc_khz =3D { } }; =20 +#ifdef CONFIG_KVM +static bool vmx_vmcs12_needed(void *opaque) +{ + struct kvm_nested_state *nested_state =3D opaque; + return (nested_state->size > offsetof(struct kvm_nested_state, + vmx.data[0].vmcs12)); +} + +static const VMStateDescription vmstate_vmx_vmcs12_state =3D { + .name =3D "cpu/kvm_nested_state/vmx/vmcs12", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmx_vmcs12_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_ARRAY(vmx.data[0].vmcs12, + struct kvm_nested_state, 0x1000), + VMSTATE_END_OF_LIST() + } +}; + +static bool vmx_shadow_vmcs12_needed(void *opaque) +{ + struct kvm_nested_state *nested_state =3D opaque; + return (nested_state->size > offsetof(struct kvm_nested_state, + vmx.data[0].shadow_vmcs12)); +} + +static const VMStateDescription vmstate_vmx_shadow_vmcs12_state =3D { + .name =3D "cpu/kvm_nested_state/vmx/shadow_vmcs12", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmx_shadow_vmcs12_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_ARRAY(vmx.data[0].shadow_vmcs12, + struct kvm_nested_state, 0x1000), + VMSTATE_END_OF_LIST() + } +}; + +static bool vmx_nested_state_needed(void *opaque) +{ + struct kvm_nested_state *nested_state =3D opaque; + + return ((nested_state->format =3D=3D KVM_STATE_NESTED_FORMAT_VMX) && + (nested_state->vmx.vmxon_pa !=3D -1ull)); +} + +static const VMStateDescription vmstate_vmx_nested_state =3D { + .name =3D "cpu/kvm_nested_state/vmx", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmx_nested_state_needed, + .fields =3D (VMStateField[]) { + VMSTATE_U64(vmx.vmxon_pa, struct kvm_nested_state), + VMSTATE_U64(vmx.vmcs_pa, struct kvm_nested_state), + VMSTATE_U16(vmx.smm.flags, struct kvm_nested_state), + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription*[]) { + &vmstate_vmx_vmcs12_state, + &vmstate_vmx_shadow_vmcs12_state, + NULL, + } +}; + +static bool svm_nested_state_needed(void *opaque) +{ + struct kvm_nested_state *nested_state =3D opaque; + + return (nested_state->format =3D=3D KVM_STATE_NESTED_FORMAT_SVM); +} + +static const VMStateDescription vmstate_svm_nested_state =3D { + .name =3D "cpu/kvm_nested_state/svm", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D svm_nested_state_needed, + .fields =3D (VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; + +static bool nested_state_needed(void *opaque) +{ + X86CPU *cpu =3D opaque; + CPUX86State *env =3D &cpu->env; + + return (is_vmx_enabled(env) && vmx_nested_state_needed(env->nested_sta= te)) || + (is_svm_enabled(env) && svm_nested_state_needed(env->nested_sta= te)); +} + +static int nested_state_post_load(void *opaque, int version_id) +{ + X86CPU *cpu =3D opaque; + CPUX86State *env =3D &cpu->env; + struct kvm_nested_state *nested_state =3D env->nested_state; + uint32_t min_nested_state_len =3D offsetof(struct kvm_nested_state, da= ta); + uint32_t max_nested_state_len =3D kvm_max_nested_state_length(); + + /* + * If our kernel don't support setting nested state + * and we have received nested state from migration stream, + * we need to fail migration + */ + if (max_nested_state_len =3D=3D 0) { + error_report("Received nested state when kernel cannot restore it"= ); + return -EINVAL; + } + + /* + * Verify that the size of received nested_state struct + * at least cover required header and is not larger + * than the max size that our kernel support + */ + if (nested_state->size < min_nested_state_len) { + error_report("Received nested state size less than min: " + "len=3D%d, min=3D%d", + nested_state->size, min_nested_state_len); + return -EINVAL; + } + if (nested_state->size > max_nested_state_len) { + error_report("Recieved unsupported nested state size: " + "nested_state->size=3D%d, max=3D%d", + nested_state->size, max_nested_state_len); + return -EINVAL; + } + + /* Verify format is valid */ + if ((nested_state->format !=3D KVM_STATE_NESTED_FORMAT_VMX) && + (nested_state->format !=3D KVM_STATE_NESTED_FORMAT_SVM)) { + error_report("Received invalid nested state format: %d", + nested_state->format); + return -EINVAL; + } + + return 0; +} + +static const VMStateDescription vmstate_kvm_nested_state =3D { + .name =3D "cpu/kvm_nested_state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_U16(flags, struct kvm_nested_state), + VMSTATE_U16(format, struct kvm_nested_state), + VMSTATE_U32(size, struct kvm_nested_state), + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription*[]) { + &vmstate_vmx_nested_state, + &vmstate_svm_nested_state, + NULL + } +}; + +static const VMStateDescription vmstate_nested_state =3D { + .name =3D "cpu/nested_state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D nested_state_needed, + .post_load =3D nested_state_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT_POINTER(env.nested_state, X86CPU, + vmstate_kvm_nested_state, + struct kvm_nested_state), + VMSTATE_END_OF_LIST() + } +}; +#endif + static bool mcg_ext_ctl_needed(void *opaque) { X86CPU *cpu =3D opaque; @@ -1148,6 +1327,9 @@ VMStateDescription vmstate_x86_cpu =3D { &vmstate_msr_intel_pt, &vmstate_msr_virt_ssbd, &vmstate_svm_npt, +#ifdef CONFIG_KVM + &vmstate_nested_state, +#endif NULL } }; --=20 2.21.0 From nobody Thu May 2 10:14:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1560559946; cv=none; d=zoho.com; s=zohoarc; b=HUHKUOOggx/LLJAEdex3nDH1HoQFylAIkpJgcvBRrW93g5i5xFTYJxanisHy2mb2Y5IGti2soHSKUXJPcv7JlgoT6d10ZV+32PuRI1ApyZBNlvlY9HC9f04OqFql6OmJPDvdbFzgtksduJblNnR0PkNJqWals0zUTkIZircnWbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560559946; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VSAtqp8UmPIPF0lSVxm2zpXVeEB/VlNEVkegW+jAWto=; b=Q6W6N7JUxpj7icvyO6Zk3GqiFDms5fBo4eo+hDdeBT3Zdcp+AegQPjDQCgagYWq3Ajgk7qFEm6O85XbC3VgOMNI6Ly+hO8qBM6+OWLMrinKiIsyhlQP/lLAS2Xz5UmZvqU9kB69stql5ET5REXMzVdPhn6UjgNrFtI4N/1K7kWA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560559946876183.9120222076832; Fri, 14 Jun 2019 17:52:26 -0700 (PDT) Received: from localhost ([::1]:57858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwvf-0006XL-Ub for importer@patchew.org; Fri, 14 Jun 2019 20:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60496) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbwmh-0000Wk-L2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbwmf-0004IS-QX for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:07 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbwmf-0004Ef-Jg for qemu-devel@nongnu.org; Fri, 14 Jun 2019 20:43:05 -0400 Received: by mail-wr1-x442.google.com with SMTP id n4so4239106wrs.3 for ; Fri, 14 Jun 2019 17:43:04 -0700 (PDT) Received: from donizetti.lan ([2001:b07:6468:f312:1da0:213e:1763:a1a8]) by smtp.gmail.com with ESMTPSA id m21sm3774234wmc.1.2019.06.14.17.43.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 17:43:01 -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 :mime-version:content-transfer-encoding; bh=VSAtqp8UmPIPF0lSVxm2zpXVeEB/VlNEVkegW+jAWto=; b=mQTNWfv0MEeJAID9VISf9tlh2krgWNY10ceVQev+Hm/iZO4lQpqgIOchNWLdpmugFr qWZvzWhubVIBEG0W855fIxBosd2AxQIBlkBfQjwfdKFNnJZ/g4PY0VfpUu1VsjDw6/wS H5Vpo702rKHbk4T0I5LmY1ADdyLpFXiDNkIrlj8OCPDcZmQs9HQMUvzsupDls080bmFa Rh55XjONxktyYFNGQqvFkGGAxqjoFJ1Ys3nAKuYo5xzOwwuUeDUiNOqc+TtVcWJEwX2O X+YyqyJXZ123m1XRdBw6uHSvqUuYR8W+GosfcA/ZXqWJTKNAUBN9vtygBHWWs2ygIAaO jzWg== 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:mime-version:content-transfer-encoding; bh=VSAtqp8UmPIPF0lSVxm2zpXVeEB/VlNEVkegW+jAWto=; b=VY/mIwyOnCUNCLlZ670fXu8u9xCY0SBE9vlXw846+rxc1tMrpIqkfiXQu2QiMSy9tt JKW6oLaiO5JdY6J9KRt1j5OhCGPjC1qNH8sLEixiwjLAxN4fFDTCGt+zR5Jy1ciqd9BE cjL2qFzWeBuI/TvbbDcwXfGnm+ebGZnnz4VDlNs4Cpl3KnX2ivEdx3tuFbTRcE5usWB7 w5oFw+GTAFFjiJ+Qj7YX1qEIf9ee39KApUHnKwlPnrY/ImG7gCRlHpPi/vc9nlluhcmM iDnrLMv1JVCWtXMkt8o5FFOyn9GWZBdvVd0Tz0Zl8CzGqVFyF9ZkywH0mWcKOam5RjLL fkVA== X-Gm-Message-State: APjAAAUFLRmL7s+NHxX/KTB7GKIhu0pD+0qJ38FzFtGBe3Hr6WKAipbu 1ygAfisozBYX6STXH/pE5eQHrxfe X-Google-Smtp-Source: APXvYqzNc2/szIx/XDP5SmVIdxaeA2yT35FduiOPnQCZXnk7NIIKdTeFgaxstApzGiIP7a6wg9YGeg== X-Received: by 2002:adf:9dcc:: with SMTP id q12mr16787543wre.93.1560559383028; Fri, 14 Jun 2019 17:43:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 15 Jun 2019 02:42:56 +0200 Message-Id: <20190615004256.16367-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190615004256.16367-1-pbonzini@redhat.com> References: <20190615004256.16367-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH 7/7] Revert "target/i386: kvm: add VMX migration blocker" 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@oracle.com, nikita.leshchenko@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon This reverts commit d98f26073bebddcd3da0ba1b86c3a34e840c0fb8. The commit should be reverted because we now support nVMX migration. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index d48fafa22b..0a01f40e73 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -943,7 +943,6 @@ static int hyperv_init_vcpu(X86CPU *cpu) } =20 static Error *invtsc_mig_blocker; -static Error *vmx_mig_blocker; =20 #define KVM_MAX_CPUID_ENTRIES 100 =20 @@ -1308,17 +1307,6 @@ int kvm_arch_init_vcpu(CPUState *cs) !!(c->ecx & CPUID_EXT_SMX); } =20 - if ((env->features[FEAT_1_ECX] & CPUID_EXT_VMX) && !vmx_mig_blocker) { - error_setg(&vmx_mig_blocker, - "Nested VMX virtualization does not support live migrat= ion yet"); - r =3D migrate_add_blocker(vmx_mig_blocker, &local_err); - if (local_err) { - error_report_err(local_err); - error_free(vmx_mig_blocker); - return r; - } - } - if (env->mcg_cap & MCG_LMCE_P) { has_msr_mcg_ext_ctl =3D has_msr_feature_control =3D true; } --=20 2.21.0