Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4053098pxv; Tue, 13 Jul 2021 09:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6iZxs3iKiIEKEiHQbttfGg9TgIclh0osb6xAaX3lMMQabGpJjArYleoclRiFEIQzT4e+5 X-Received: by 2002:a17:906:49ce:: with SMTP id w14mr6765944ejv.273.1626194360914; Tue, 13 Jul 2021 09:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626194360; cv=none; d=google.com; s=arc-20160816; b=AptZBiNGfJKecdAp1dwZalbPFbsfL5nfLjo9J0gvPrVJngqTuc1kxGL6CvxjjVniSW oCXSa3j9+suTcnBgZxyjM7HG2s0biBlArxwvCHRQo9JLO8+IEHyoPI+kh+y5vlyUAaz/ wCdmtcJDPWR5HRQPGlrUZAe4laeKfDfSWtDPxjuYCIozMk/XLJ5VSI4ttR6RJ7Ijpi+r udxqOdfboLAikeOrZtoWimtuEPnRsl6047UXT+G6C4Txz1au6knElOx6PijPelTQoj9a 6htgnkYba/XgLFip6Ysoi/plyEaa6B2hKajy8SP2Er+IM0N1Dv93i8jWY3KISRU4Bjyj TY3w== 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=+E9aSBRBRnkdWbZXjoXlsgbyRNBB/RIBNAs/dlJauCk=; b=vVDehNaOg+XYLRj1GgF7zoWtzlZvtP8MscrQ85+Q4SDqLDev6eUm18VStga0jZh3Ex iFEfzqHNxj32gE7ptKzjn75Brfj6EKmO9yWlfqkRDlhMksGDY7ZdP8F016dpXEcLKHhD APt4JzYJYrSxxZYu/qe5nNASOKQMlQtquMxgTvBjMGQroKOQ2NMei7AFEmHGligk/XHj vs1KIXFqZkfQsYI6UxFlv2GUxlfYyP3LlD/AeUYHrvSkKDiwm1yOykqcrQI4UNA1MTOC LxJ9sVa8+H1YdYC51+Dx5l/yLqg8GLjuSsXEhR+4vqZkp+g3wLHAf+xs3ppVIbJkx39Y OEUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="NSZq/SEF"; 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 q5si21170111ejt.588.2021.07.13.09.38.57; Tue, 13 Jul 2021 09:39:20 -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="NSZq/SEF"; 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 S234395AbhGMQiT (ORCPT + 99 others); Tue, 13 Jul 2021 12:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234540AbhGMQiE (ORCPT ); Tue, 13 Jul 2021 12:38:04 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7E64C05BD0C for ; Tue, 13 Jul 2021 09:34:35 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id q2-20020ad45ca20000b02902b1554c2318so17698501qvh.11 for ; Tue, 13 Jul 2021 09:34:35 -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=+E9aSBRBRnkdWbZXjoXlsgbyRNBB/RIBNAs/dlJauCk=; b=NSZq/SEFDbfPCXS71NJBAFGp8Ig+zn4LbogUdovO0aC2VBPEqD/YgmNxIzbsQxJRU9 JqVDzETYLL2xbaTjHMcVEUKGtUE21NrFz9r4FqlCODoda+38sDeHSySrDElfOYHpAL+U 0lcH2CitPsirGgl1hYsFeLMnxRcAugs3O28lyTLI0J1mXzg+fk2w0cGcmkId9rDJ7XjO uWRWQSmIljDT9iQVrv5Y4sNGok5ZlU9w+JdFyEJj1v/zlx/AEt5DzSzMUjyo9M5WiayP NL6pgXe8BIbT8bf2mkEQTqNrlugEBobTil/y6lCsuythfDFpU8QOhm4FqrWPsQyaK19S YHzA== 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=+E9aSBRBRnkdWbZXjoXlsgbyRNBB/RIBNAs/dlJauCk=; b=Y+9lXVBQNTaFNn5KFjVclNUqqYBIfJJAsiTCJ8ln2R8eSnr2YVgCnOZEwWt6tkcITv MnrUbXq9pEiR1qgq5n9YOIx05bamP+9kTeg+jO/Gc2aog6XVNfCEUfWjm+QeD3mr5xn3 w1Fieajq0I65AoO0/oTXm4qnkCnSfaJP1uWQwAosdNf/Oc0SOg35sPvNY8eM4wv91Y6y YiNOKMnRWuR3H+ZnXGRoMtGn1b3MfOiVJCRbwRXKHN/N0zL6C+Nu1h+iqz5VKLzT4w/B dEX4CGJo355+UkATHWTMear5aj1uNlNbzx1b/J1PtPBP3TKVMpIJISwxB+FM6PzO5MaB rS+w== X-Gm-Message-State: AOAM531FCsFwg2NMvx0CjRs0WEGKAZD7K0dfFBO84XNyTyr5tUk1ran3 VNsnJ5ww850iJ+RUbMlS9L+VDbK+Q9Q= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:825e:11a1:364b:8109]) (user=seanjc job=sendgmr) by 2002:ad4:568a:: with SMTP id bc10mr5808858qvb.20.1626194074843; Tue, 13 Jul 2021 09:34:34 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 13 Jul 2021 09:33:10 -0700 In-Reply-To: <20210713163324.627647-1-seanjc@google.com> Message-Id: <20210713163324.627647-33-seanjc@google.com> Mime-Version: 1.0 References: <20210713163324.627647-1-seanjc@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH v2 32/46] 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, Reiji Watanabe 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 8d36f0c73071..e34ee60fc9d7 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -583,6 +583,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 6eff7f1a4672..251b230b2fef 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1265,7 +1265,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.32.0.93.g670b81a890-goog