Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1795528pxy; Fri, 23 Apr 2021 17:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2P0Eas4fpapN9v1l14JJRjL0XJAknNnb6dc3wuAhLDhDf0jsjPoqAi8iCKJm1tHRhWFJo X-Received: by 2002:aa7:c65a:: with SMTP id z26mr5392940edr.305.1619225719282; Fri, 23 Apr 2021 17:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619225719; cv=none; d=google.com; s=arc-20160816; b=kKhUKP9Ck/lOWLn/U7atHKeb4Z7ugWzFv+ef6JZ04yS8NYl/i9yny7323JTdwgLH29 TqtHIrNUOKJmTJXctUYrFbUvp/sOYp4W7VndPECNHwerTW6M5kZ+54LkHRhnrDxKaLAH eq3C8QVtuFhodhC0r6ekSGKFBtYIfcPrQhKUF6Say0jOlc7ouICaof+NqNnKG9rQyXnC 7Qpv/LYvfyFJNM9JZut6JF9GthbTIHMiBJht5at7d8ASheNlDHTSXQKBQTU0zqEhgEg4 EeSSK6JtwoKqaaPT/yB3OtYVN+rJ1qMQpYn470yD/wEGXpD5dHJyyFRwALcz6afFeZ8u 7+Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=sHAT3f/Z7rzeqzw1crWe70jwssZuJ3ZwjfFXfNoL22E=; b=EaSsK4XkiHbdbjTLvdfTkjGCitibWI57CmzdoxLw3WFNAPpxc6KSPIBfymcRN7i1rQ VC/Hypst8a11566OLwlpP8fyi3x9TlBkaJksnuGb5O34TkYAFWuCdUmiP0wWA/fKKpgB Ee2q1TeSa8bL8YWy2LQjT/ZnvFBysGviQ1exy/gP5Y1hY35phDws58Pm3MA8WiLvY5Zh OtlJK9t4nETL+lE47xyKjOrwqRzkyrsxYMBRcMeJuOTn3q7mxJWotwfCBsrIFf5yMHWh lsHQNg5i7A2uOH5UyfAgOe0KhmAfD1dwcs3N0at/gtJKjfOOmabHPRi7u4fyDqfqhqTN BAHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uAjiVALH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si6608441edv.581.2021.04.23.17.54.56; Fri, 23 Apr 2021 17:55:19 -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=@google.com header.s=20161025 header.b=uAjiVALH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244307AbhDXAyd (ORCPT + 99 others); Fri, 23 Apr 2021 20:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244402AbhDXAxD (ORCPT ); Fri, 23 Apr 2021 20:53:03 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBA5C0612ED for ; Fri, 23 Apr 2021 17:48:09 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id n129-20020a2527870000b02904ed02e1aab5so14641128ybn.21 for ; Fri, 23 Apr 2021 17:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=sHAT3f/Z7rzeqzw1crWe70jwssZuJ3ZwjfFXfNoL22E=; b=uAjiVALHwTJh6zDtWgM6ZZ6gfTE8VT2Z3/yzpWjbaXccVMu2ELKEuSKDYxBnbfqEKG aUpmmY3b721f/yOLcO18vtQfjUmjNHwLXEi3F1KAcSbjMd/a/cgUnnt+98/jl2gEoKM0 01t2k8Vwp/zIQQnTIMgQNz7Re5nZCi/BmdeBxXntF4xPl5WZzxFctkPhuP2VeDYPdV3T W6duE03AG3gqc1yODwV1LhoredzgkaaN1mVC5tuWy4zcJ4r+IMVrbdwk9Og2m5YSJQxj 4JAnvsUl3F/9DqUTnQDZgohvq70D9MVepoignzuybt32IPsjxraTRKxhCVYJNJTE5f5F Rncg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=sHAT3f/Z7rzeqzw1crWe70jwssZuJ3ZwjfFXfNoL22E=; b=MalBDuQq94hubgFwOZnLov6nAx3N84MS/NuUefGIiMb4UJH1LGStQHuPdD2ZIux9cn YX4FY0kPes6XK8nipZkm4NRY/GVfbtqXGmgK5tGVWzvxCEL+xA2aNYUtN9GoDCG/pe9W mw4AewF8P7F5U0aWHgUTcXnwCbnby0GW52sWzp+aiOAqcd9SkGZXVqx2nAshlLH+AafL Vg/D5EpmMhyLcSTmy4CGqTpsQQME22RLM47szuIhm98dGDSZlOJ4SCS70oap2GO279by /7ylQhi8Pr0VdsBBxLdC/+NettcWzJIN2GPfYZv0Dd992vl0o0daLzaVm2/f97lY3j5U WaJg== X-Gm-Message-State: AOAM530TnAN2Vo4jiOS1EFk3teylWtya1l1KepOYLhdoHsnlo3MWIccq ZeTM6MY/ZsIuAaNiJNx2pvvwpHoESrg= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:ad52:3246:e190:f070]) (user=seanjc job=sendgmr) by 2002:a25:bd83:: with SMTP id f3mr9374328ybh.29.1619225288761; Fri, 23 Apr 2021 17:48:08 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 23 Apr 2021 17:46:33 -0700 In-Reply-To: <20210424004645.3950558-1-seanjc@google.com> Message-Id: <20210424004645.3950558-32-seanjc@google.com> Mime-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 31/43] KVM: SVM: Stuff save->dr6 at during VMSA sync, not at RESET/INIT From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move code to stuff vmcb->save.dr6 to its architectural init value from svm_vcpu_reset() into sev_es_sync_vmsa(). Except for protected guests, a.k.a. SEV-ES guests, vmcb->save.dr6 is set during VM-Enter, i.e. the extra write is unnecessary. For SEV-ES, stuffing save->dr6 handles a theoretical case where the VMSA could be encrypted before the first KVM_RUN. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 1 + arch/x86/kvm/svm/svm.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index a9d8d6aafdb8..b81ebeb4c426 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -573,6 +573,7 @@ static int sev_es_sync_vmsa(struct vcpu_svm *svm) save->xcr0 = svm->vcpu.arch.xcr0; save->pkru = svm->vcpu.arch.pkru; save->xss = svm->vcpu.arch.ia32_xss; + save->dr6 = svm->vcpu.arch.dr6; /* * SEV-ES will use a VMSA that is pointed to by the VMCB, not diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 558329f53709..996a6b03e338 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1207,7 +1207,6 @@ static void init_vmcb(struct kvm_vcpu *vcpu) svm_set_cr0(vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET); svm_set_cr4(vcpu, 0); svm_set_efer(vcpu, 0); - save->dr6 = 0xffff0ff0; kvm_set_rflags(vcpu, X86_EFLAGS_FIXED); vcpu->arch.regs[VCPU_REGS_RIP] = 0x0000fff0; -- 2.31.1.498.g6c1eba8ee3d-goog