From: Paolo Bonzini <pbonzini@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org
Subject: Re: [PATCH] target/i386: svm: fix sign extension of exit code
Date: Mon, 17 Nov 2025 12:32:21 +0100 [thread overview]
Message-ID: <851ab1f1-c05b-48e9-a08d-2076fa9ab67c@redhat.com> (raw)
In-Reply-To: <3e215a17-11ed-4172-9598-42a2e1bd9e9e@linaro.org>
On 11/17/25 10:42, Richard Henderson wrote:
> On 11/15/25 01:26, Paolo Bonzini wrote:
>> -void cpu_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t
>> exit_info_1,
>> +void cpu_vmexit(CPUX86State *env, uint64_t exit_code, uint64_t
>> exit_info_1,
>> uintptr_t retaddr)
>> {
>> CPUState *cs = env_cpu(env);
>> @@ -732,7 +732,7 @@ void cpu_vmexit(CPUX86State *env, uint32_t
>> exit_code, uint64_t exit_info_1,
>> qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmexit(%08x, %016" PRIx64 ",
>> %016"
>> PRIx64 ", " TARGET_FMT_lx ")!\n",
>> - exit_code, exit_info_1,
>> + (uint32_t)exit_code, exit_info_1,
>
> Why cast instead of printing all 64 bits?
Because in practice exit_code is either a very small negative value
(-1...-4) or a positive value. For QEMU in addition the positive value
will also be small (less than 16 bits); values between 0x8000_0000 and
0xffff_ffff could happen in principle but are for use by software and by
the processor[1]. So the high 32 bits are basically unused, and the
cast removes eight zeroes or f's from the log.
Paolo
[1] see for example arch/x86/include/uapi/asm/svm.h in Linux:
#define SVM_VMGEXIT_MMIO_READ 0x80000001
#define SVM_VMGEXIT_MMIO_WRITE 0x80000002
#define SVM_VMGEXIT_NMI_COMPLETE 0x80000003
#define SVM_VMGEXIT_AP_HLT_LOOP 0x80000004
#define SVM_VMGEXIT_AP_JUMP_TABLE 0x80000005
#define SVM_VMGEXIT_PSC 0x80000010
#define SVM_VMGEXIT_GUEST_REQUEST 0x80000011
#define SVM_VMGEXIT_EXT_GUEST_REQUEST 0x80000012
#define SVM_VMGEXIT_AP_CREATION 0x80000013
#define SVM_VMGEXIT_SNP_RUN_VMPL 0x80000018
#define SVM_VMGEXIT_SAVIC 0x8000001a
#define SVM_VMGEXIT_HV_FEATURES 0x8000fffd
#define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe
#define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff
#define SVM_EXIT_SW 0xf0000000
SVM_VMGEXIT_* values are actually stored by the guest in its own memory,
not by the processor; whereas SVM_EXIT_SW is only used in nested
virtualization scenarios and will not be passed to cpu_vmexit.
next prev parent reply other threads:[~2025-11-17 11:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-15 0:26 [PATCH] target/i386: svm: fix sign extension of exit code Paolo Bonzini
2025-11-17 9:42 ` Richard Henderson
2025-11-17 11:32 ` Paolo Bonzini [this message]
2025-11-18 8:31 ` Richard Henderson
2025-11-18 13:07 ` Paolo Bonzini
2025-11-19 10:59 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=851ab1f1-c05b-48e9-a08d-2076fa9ab67c@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.