From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mx.groups.io with SMTP id smtpd.web11.10951.1631725710932826372 for ; Wed, 15 Sep 2021 10:08:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@google.com header.s=20210112 header.b=Gx2qf7Wc; spf=pass (domain: google.com, ip: 209.85.216.46, mailfrom: erdemaktas@google.com) Received: by mail-pj1-f46.google.com with SMTP id w19-20020a17090aaf9300b00191e6d10a19so2711474pjq.1 for ; Wed, 15 Sep 2021 10:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=98eYFYkwFNDpDyZTQaHvz9iEmFcvFCKqwcm/1rlPfvg=; b=Gx2qf7WckR+bWl04t7kFm7wnFP5AeqaTyHvpZ+/9Canavh+Tnj3pNt385yDgN8Eiu1 f3Bwbq9FEj9kldg85vXlm416WJJvwFmk5PYDtCbRYRKyYkDnfTy8EcZimjjBHiKLXf9q bOTFVMUMWlSXhHXldLsUMHl3eIpdAsTlpHujRBxT3aB+PFQkeeQMDlsXlJRYxIuoULMQ ftMJPhHMHvkaT6S+ERKqI1YpSqhdXk/pC1NQgZ9WjnqO/6KpKa9cbTnWzQGdH8AljfDW N3eKnbF37vEq6OgP/Y1GOwYXzaXuBwJr9PHfjqjh9PuoVhQTQjly1twD5WJ5aPDYPElB KByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=98eYFYkwFNDpDyZTQaHvz9iEmFcvFCKqwcm/1rlPfvg=; b=DDmYYJfLEyZ8lwwnQoO1uBM1wz3pFDkaFBhBfsfdi2jVdR7zVaW/IovpD8PbKDYnNE 48mgvhejooLggcHfVTLdplYjXhlVa8N4VpyDJb/ZwU3U7CSyTHzMWe6MTFEpEU2HTaF1 pX16qfxFDUxuG3uDV/UgfiNSpGQKyKPQD0opRCP7Tpk+jkT+Azqp9Au8RIoIGIzebK3F N86MhnMVBQ2XgF57580/Kxg26bQLHaJlM8ZUDP1kKlXpxBTtCiQNb9I+aPsvCfFoRXUf eTT8eoYW+ipAvQrS9vWs9Z4ICiiJwMdVoCyKZ14KPCFSAdm/4CGwZIf5aa984fQgJ0pW 7lmA== X-Gm-Message-State: AOAM530OjEejxZrKBb1pC2M0S12pMuBaUSwchyXVJepwEBz8Kr3GppyZ 6OE1EuzwAXjbdzvo0Y0CdlzfDMbT2L3IJwnNBrK4Mw== X-Google-Smtp-Source: ABdhPJymnwuAUCh0tYpTosgLM99FQj1y9Lolttg6PAqskuGqymsjPJoHjoj3zpo6DTnciWDRtLvRMR+aC2nWkTmRi3k= X-Received: by 2002:a17:90a:cf0d:: with SMTP id h13mr857991pju.61.1631725710085; Wed, 15 Sep 2021 10:08:30 -0700 (PDT) MIME-Version: 1.0 References: <20210913181941.23405-1-brijesh.singh@amd.com> <20210913181941.23405-10-brijesh.singh@amd.com> In-Reply-To: <20210913181941.23405-10-brijesh.singh@amd.com> From: "Erdem Aktas" Date: Wed, 15 Sep 2021 20:08:19 +0300 Message-ID: Subject: Re: [PATCH v7 09/31] OvmfPkg/SecMain: register GHCB gpa for the SEV-SNP guest To: Brijesh Singh Cc: edk2-devel-groups-io , James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Michael Roth , Gerd Hoffmann Content-Type: text/plain; charset="UTF-8" On Mon, Sep 13, 2021 at 9:20 PM Brijesh Singh wrote: > +*/ > +STATIC > +VOID > +SevSnpGhcbRegister ( > + UINTN Address > + ) > +{ > + MSR_SEV_ES_GHCB_REGISTER Msr; > + MSR_SEV_ES_GHCB_REGISTER CurrentMsr; > + EFI_PHYSICAL_ADDRESS GuestFrameNumber; > + > + GuestFrameNumber = Address >> EFI_PAGE_SHIFT; > + > + // > + // Save the current MSR Value > + // > + CurrentMsr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB); We are backing the current MSR value but when was it initialized before ? Also is not this function supposed to set the Address as the GHCB address? If it is, do we care about the old value? > + // Restore the MSR > + // > + AsmWriteMsr64 (MSR_SEV_ES_GHCB, CurrentMsr.GhcbPhysicalAddress); Why are we restoring the old value? I may have misunderstood but I thought this function will set Address as the new GHCB address? Thanks -Erdem