Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5424159pxv; Wed, 7 Jul 2021 03:30:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6SxdbGt+UMWB5N3ljng4VLMw/JWbSrnfp9gwOHan3iAsZyr8fdijh5cNsGSfKjQmlz1OT X-Received: by 2002:a92:a806:: with SMTP id o6mr18251333ilh.53.1625653857368; Wed, 07 Jul 2021 03:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625653857; cv=none; d=google.com; s=arc-20160816; b=E+69pjJ5xjTQRii1Qei977nIknfdF5R+j1YJU8aVMJJB5srfJ1Qea0yjkKIkGpbi3n 2Tpx8nIi1JRwrffEG8VQSqtvZ1Wso6g62FgACZdkgna5GH+8haaSscwG0JPtxiJw2sYP mtY5T6JeTUwdnvDJ3aZLA2B/3kVzlFXqn7966aDHjH4CMbzj5WNVw8I+iC3z677wxA3R l9P2Z2bA2SSpJRpywqeYKg/Y2L+uWrZN5fKOyeB0kdACfGqqmjsnmzvPrYv0eN/V0Arl kGKUPbfkeaYO7Z6P33v6TOxfYgoA1qdZI1g7OvFypmoQau+TM9rQS8zqnyvRxVYzjf+v Qs0Q== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=R31OBQCGxDbFDo5h14oM1SM1akB7TTfct9Ykk8ny+hw=; b=Gl1s4MmkqK9ITwO8Q4owLrVRoTb6zKq7WTltVuST5CaLJ51/tvMEdGswjX15GOGYLM fva6tFAI/r+ATl0q7RfFyysnJ7ieuY0ThIMKvAC14MCcYo4al05DV4uAmrXjGgolh05W 7ET+AtFtLfBSTOgy9aSmdODmuMQEOuqziaQDJddlhlGR3Hz7Bex87dSi8rxJUdP3X1k3 4FY/x6PB12c3fRAMm6t/1vo35LXE/2Jten6+fHcaJ6rRqo0iCuWOnYFQpqCgTUY/odO9 CvFnpwhM64RUcLttQEDhA8wtWTMVVeOKDerI+3J6FxUrVJ9FxjO1HNjyuR1meLGdB1l2 yPHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IU8V23+4; 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 j12si20965729jar.85.2021.07.07.03.30.45; Wed, 07 Jul 2021 03:30:57 -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=IU8V23+4; 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 S231332AbhGGKbT (ORCPT + 99 others); Wed, 7 Jul 2021 06:31:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58466 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbhGGKbS (ORCPT ); Wed, 7 Jul 2021 06:31:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625653717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R31OBQCGxDbFDo5h14oM1SM1akB7TTfct9Ykk8ny+hw=; b=IU8V23+4T8ES3UHnJv8fRVpar4fxOZBlzeSKp7bPIg2Rz+itcj2iiRnEOH/SGE6u/X7vci Khj6YqqXEq3ylSlAz+hWFH7nyhWI9gYdKoSXa6jCnl+Crh4bUi7XgEpM+ZqCPnYJwhLCn5 81Z2UTMSphhyUU5j2O5SM+e+vNzVNOQ= 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-38-_fq_S3AuNgmH43JCikXP6Q-1; Wed, 07 Jul 2021 06:28:34 -0400 X-MC-Unique: _fq_S3AuNgmH43JCikXP6Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8376E100CCC0; Wed, 7 Jul 2021 10:28:33 +0000 (UTC) Received: from starship (unknown [10.40.192.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 143CD5D9D3; Wed, 7 Jul 2021 10:28:26 +0000 (UTC) Message-ID: <0e00f5ecfcd8c01560abf872b648ae29999e8f01.camel@redhat.com> Subject: Re: [PATCH 2/6] KVM: nSVM: Check that VM_HSAVE_PA MSR was set before VMRUN From: Maxim Levitsky To: Vitaly Kuznetsov , kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Cathy Avery , Emanuele Giuseppe Esposito , Tom Lendacky , Michael Roth , linux-kernel@vger.kernel.org Date: Wed, 07 Jul 2021 13:28:25 +0300 In-Reply-To: <20210628104425.391276-3-vkuznets@redhat.com> References: <20210628104425.391276-1-vkuznets@redhat.com> <20210628104425.391276-3-vkuznets@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-06-28 at 12:44 +0200, Vitaly Kuznetsov wrote: > APM states that "The address written to the VM_HSAVE_PA MSR, which holds > the address of the page used to save the host state on a VMRUN, must point > to a hypervisor-owned page. If this check fails, the WRMSR will fail with > a #GP(0) exception. Note that a value of 0 is not considered valid for the > VM_HSAVE_PA MSR and a VMRUN that is attempted while the HSAVE_PA is 0 will > fail with a #GP(0) exception." > > svm_set_msr() already checks that the supplied address is valid, so only > check for '0' is missing. Add it to nested_svm_vmrun(). > > Signed-off-by: Vitaly Kuznetsov > --- > arch/x86/kvm/svm/nested.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c > index 21d03e3a5dfd..1c6b0698b52e 100644 > --- a/arch/x86/kvm/svm/nested.c > +++ b/arch/x86/kvm/svm/nested.c > @@ -618,6 +618,11 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu) > struct kvm_host_map map; > u64 vmcb12_gpa; > > + if (!svm->nested.hsave_msr) { > + kvm_inject_gp(vcpu, 0); > + return 1; > + } > + > if (is_smm(vcpu)) { > kvm_queue_exception(vcpu, UD_VECTOR); > return 1; Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky