Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4240995pxk; Tue, 22 Sep 2020 14:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3KqfYk1WvtMFtb3t+d/14jJssqod3uSkGyAH0np9R0+GudRffD1qedlDnjQeFWtYG8MQE X-Received: by 2002:a17:906:d9d9:: with SMTP id qk25mr6909174ejb.51.1600809122639; Tue, 22 Sep 2020 14:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600809122; cv=none; d=google.com; s=arc-20160816; b=fShY+fGBW/XvyAXZSR5K+VHXoH/YVM+LJn3nWntCVnxLWmON2SXIdwb8Wi0tnu6HJ/ 0ye/Qa5Xht0hmHa+GYMm8u29JJkf4O3StzmrMtmEswzelhZ4wSxVpdYkZ3xxGcXOSwy+ 7BNHUoS92kZxbmA3KIpF6R/E0lYIuxuigNUOkKUkECI0I2WMRAc7z/h5ZO4N8E7Z7DUo GzsYQ12D7cxus5p8k8jOIMBWLpWW3Sdg6AX4NGeUoCIDO3rIhMfck1FXOr6BM794+K2e blCC8/TKL27UzMmrPbjlJ4crn0csLeVYxd4gC2Xv/ulY7FsFeR+herq80iNxNxmhALtY PaxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bNjVgWpgtIkPhRa8XVCPnausw2GfEoBb82DdGdZXVvc=; b=aq23QiIUZulGNDPcP7cALoONYr7Hp3Xdb/DqmrUPf41QXLO1CuCdic5p7+Sgqfs+vd m/ha4Ldhzvs57hQU6WAJzlbGd31duI269gahXBz1xnxf8luvzxe68s0YUhy6sIrka/tf 9eIajZGFDanpZKKjmUMIZ23nnOx4JuS58EKi+vzceNDWu/sfoSgQSO52nToDeIPS4RTd 1vQCa90BReU+DW0yS9PB6OhXRMFxcVHHLAxYAv0lHI/VIQ5jVVhpsuJoKfiz9cOJ+5qr jL//wQE2xxIXswHvsZHzsdT8tu0diLzzzYcyTm+w0VnX1PUW348ZqtW4adDbc9HQ3Q9q 2/Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ekIwuyE4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z19si11207093edx.205.2020.09.22.14.11.39; Tue, 22 Sep 2020 14:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ekIwuyE4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgIVVKf (ORCPT + 99 others); Tue, 22 Sep 2020 17:10:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37014 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgIVVKf (ORCPT ); Tue, 22 Sep 2020 17:10:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600809034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=bNjVgWpgtIkPhRa8XVCPnausw2GfEoBb82DdGdZXVvc=; b=ekIwuyE46DrYdAaRR3VUm9LJ6r86ZyXtW9vna51dozcxfWozLSzNT6srwE2a0xuuuUv4XQ AEg5PntS9WxpfXwePKBvt4KyJRAGcL9RvrB036MI35X+RjLHN8wY7TVNG517Fc9UqGOOIU ahdkDAwhtTWQKy7OVlzx6mYY3DHOA3k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-EmSHZr1ePa6cO30n87NEuA-1; Tue, 22 Sep 2020 17:10:32 -0400 X-MC-Unique: EmSHZr1ePa6cO30n87NEuA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4AE01007B36; Tue, 22 Sep 2020 21:10:30 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF02155768; Tue, 22 Sep 2020 21:10:26 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: "H. Peter Anvin" , Ingo Molnar , Borislav Petkov , Vitaly Kuznetsov , Sean Christopherson , Joerg Roedel , Paolo Bonzini , Wanpeng Li , Thomas Gleixner , linux-kernel@vger.kernel.org, Jim Mattson , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Maxim Levitsky Subject: [PATCH v6 0/4] KVM: nSVM: ondemand nested state allocation Date: Wed, 23 Sep 2020 00:10:21 +0300 Message-Id: <20200922211025.175547-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is the next version of this patch series.=0D =0D In V5 I adopted Sean Christopherson's suggestion to make .set_efer return=0D a negative error (-ENOMEM in this case) which in most cases in kvm=0D propagates to the userspace.=0D =0D I noticed though that wrmsr emulation code doesn't do this and instead=0D it injects #GP to the guest on _any_ error.=0D =0D So I fixed the wrmsr code to behave in a similar way to the rest=0D of the kvm code.=0D (#GP only on a positive error value, and forward the negative error to=0D the userspace)=0D =0D I had to adjust one wrmsr handler (xen_hvm_config) to stop it from returnin= g=0D negative values so that new WRMSR emulation behavior doesn't break it.=0D This patch was only compile tested.=0D =0D The memory allocation failure was tested by always returning -ENOMEM=0D from svm_allocate_nested.=0D =0D The nested allocation itself was tested by countless attempts to run=0D nested guests, do nested migration on both my AMD and Intel machines.=0D I wasn't able to break it.=0D =0D Changes from V5: addressed Sean Christopherson's review feedback.=0D =0D Best regards,=0D Maxim Levitsky=0D =0D Maxim Levitsky (4):=0D KVM: x86: xen_hvm_config: cleanup return values=0D KVM: x86: report negative values from wrmsr emulation to userspace=0D KVM: x86: allow kvm_x86_ops.set_efer to return an error value=0D KVM: nSVM: implement on demand allocation of the nested state=0D =0D arch/x86/include/asm/kvm_host.h | 2 +-=0D arch/x86/kvm/emulate.c | 7 ++--=0D arch/x86/kvm/svm/nested.c | 42 ++++++++++++++++++++++++=0D arch/x86/kvm/svm/svm.c | 58 +++++++++++++++++++--------------=0D arch/x86/kvm/svm/svm.h | 8 ++++-=0D arch/x86/kvm/vmx/vmx.c | 6 ++--=0D arch/x86/kvm/x86.c | 37 ++++++++++++---------=0D 7 files changed, 113 insertions(+), 47 deletions(-)=0D =0D -- =0D 2.26.2=0D =0D