* [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check
@ 2023-07-14 20:28 Lendacky, Thomas
2023-07-15 0:26 ` Ard Biesheuvel
2023-09-19 7:59 ` [edk2-devel] " Gerd Hoffmann
0 siblings, 2 replies; 4+ messages in thread
From: Lendacky, Thomas @ 2023-07-14 20:28 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Jiewen Yao, Jordan Justen, Gerd Hoffmann,
Erdem Aktas, James Bottomley, Min Xu, Michael Roth
Commit 63c50d3ff2854a76432b752af4f2a76f33ff1974 changed the check that is
used to determine if SEV-ES is active. Originally, a CMP instruction with
a supporting JZ instruction was used for the check. It was changed to use
the BT instruction but not JZ instruction. The result of a BT instruction
changes the the carry flag (CF) and not the zero flag (ZF). As a result,
the wrong condition is being checked. Update the JZ to a JNC to properly
detect if SEV-ES is active.
Fixes: 63c50d3ff285 ("OvmfPkg/ResetVector: cache the SEV status MSR...")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm b/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
index c5c683ebed3e..429a58c5efd3 100644
--- a/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
+++ b/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
@@ -44,7 +44,7 @@ Transition32FlatTo64Flat:
mov ecx, 1
bt [SEV_ES_WORK_AREA_STATUS_MSR], ecx
- jz EnablePaging
+ jnc EnablePaging
;
; SEV-ES is active, perform a quick sanity check against the reported
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check
2023-07-14 20:28 [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check Lendacky, Thomas
@ 2023-07-15 0:26 ` Ard Biesheuvel
2023-09-19 7:59 ` [edk2-devel] " Gerd Hoffmann
1 sibling, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2023-07-15 0:26 UTC (permalink / raw)
To: Tom Lendacky
Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Gerd Hoffmann,
Erdem Aktas, James Bottomley, Min Xu, Michael Roth
On Fri, 14 Jul 2023 at 22:28, Tom Lendacky <thomas.lendacky@amd.com> wrote:
>
> Commit 63c50d3ff2854a76432b752af4f2a76f33ff1974 changed the check that is
> used to determine if SEV-ES is active. Originally, a CMP instruction with
> a supporting JZ instruction was used for the check. It was changed to use
> the BT instruction but not JZ instruction. The result of a BT instruction
> changes the the carry flag (CF) and not the zero flag (ZF). As a result,
> the wrong condition is being checked. Update the JZ to a JNC to properly
> detect if SEV-ES is active.
>
> Fixes: 63c50d3ff285 ("OvmfPkg/ResetVector: cache the SEV status MSR...")
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm b/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
> index c5c683ebed3e..429a58c5efd3 100644
> --- a/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
> +++ b/OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
> @@ -44,7 +44,7 @@ Transition32FlatTo64Flat:
>
> mov ecx, 1
> bt [SEV_ES_WORK_AREA_STATUS_MSR], ecx
> - jz EnablePaging
> + jnc EnablePaging
>
> ;
> ; SEV-ES is active, perform a quick sanity check against the reported
Merged as #4646
Thanks,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check
2023-07-14 20:28 [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check Lendacky, Thomas
2023-07-15 0:26 ` Ard Biesheuvel
@ 2023-09-19 7:59 ` Gerd Hoffmann
2023-09-19 13:19 ` Lendacky, Thomas via groups.io
1 sibling, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2023-09-19 7:59 UTC (permalink / raw)
To: Tom Lendacky
Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Erdem Aktas,
James Bottomley, Min Xu, Michael Roth
On Fri, Jul 14, 2023 at 03:28:26PM -0500, Tom Lendacky wrote:
> Commit 63c50d3ff2854a76432b752af4f2a76f33ff1974 changed the check that is
> used to determine if SEV-ES is active. Originally, a CMP instruction with
> a supporting JZ instruction was used for the check. It was changed to use
> the BT instruction but not JZ instruction. The result of a BT instruction
> changes the the carry flag (CF) and not the zero flag (ZF). As a result,
> the wrong condition is being checked. Update the JZ to a JNC to properly
> detect if SEV-ES is active.
What is the effect of this bug? Is it just the encryption sanity check
being skipped?
take care,
Gerd
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108817): https://edk2.groups.io/g/devel/message/108817
Mute This Topic: https://groups.io/mt/100149226/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check
2023-09-19 7:59 ` [edk2-devel] " Gerd Hoffmann
@ 2023-09-19 13:19 ` Lendacky, Thomas via groups.io
0 siblings, 0 replies; 4+ messages in thread
From: Lendacky, Thomas via groups.io @ 2023-09-19 13:19 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: devel, Ard Biesheuvel, Jiewen Yao, Jordan Justen, Erdem Aktas,
James Bottomley, Min Xu, Michael Roth
On 9/19/23 02:59, Gerd Hoffmann wrote:
> On Fri, Jul 14, 2023 at 03:28:26PM -0500, Tom Lendacky wrote:
>> Commit 63c50d3ff2854a76432b752af4f2a76f33ff1974 changed the check that is
>> used to determine if SEV-ES is active. Originally, a CMP instruction with
>> a supporting JZ instruction was used for the check. It was changed to use
>> the BT instruction but not JZ instruction. The result of a BT instruction
>> changes the the carry flag (CF) and not the zero flag (ZF). As a result,
>> the wrong condition is being checked. Update the JZ to a JNC to properly
>> detect if SEV-ES is active.
>
> What is the effect of this bug? Is it just the encryption sanity check
> being skipped?
Yes, it is just causing the mitigation check to be skipped. Because of the
previous xor instruction, the JZ instruction will always be taken.
Thanks,
Tom
>
> take care,
> Gerd
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108830): https://edk2.groups.io/g/devel/message/108830
Mute This Topic: https://groups.io/mt/100149226/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-19 13:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-14 20:28 [PATCH] OvmfPkg/ResetVector: Fix assembler bit test flag check Lendacky, Thomas
2023-07-15 0:26 ` Ard Biesheuvel
2023-09-19 7:59 ` [edk2-devel] " Gerd Hoffmann
2023-09-19 13:19 ` Lendacky, Thomas via groups.io
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox