On Sun, Nov 09, 2025 at 01:10:50PM +0000, Bernhard Beschow wrote:
> >+static int read_memory(const CPUState *cpu, uint64_t initial_gva,
> >+ uint64_t initial_gpa, uint64_t gva, uint8_t *data,
> >+ size_t len)
> >+{
> >+ int ret;
> >+ uint64_t gpa, flags;
> >+
> >+ if (gva == initial_gva) {
> >+ gpa = initial_gpa;
>
> This assignment is never read and this branch leaves `data` untouched...
>
> >+ } else {
> >+ flags = HV_TRANSLATE_GVA_VALIDATE_READ;
> >+ ret = translate_gva(cpu, gva, &gpa, flags);
> >+ if (ret < 0) {
> >+ return -1;
> >+ }
> >+
>
> while this block:
>
> >+ ret = mshv_guest_mem_read(gpa, data, len, false, false);
> >+ if (ret < 0) {
> >+ error_report("failed to read guest mem");
> >+ return -1;
> >+ }
>
> is only executed in the else branch which is inconsistent to write_memory().
> Is that intended? If so, do we really need the unused assignment above?
>
> Best regards,
> Bernhard
>
Thank you for spotting this Bernhard, this is a remnant from an attempt
to optimize gva=>gpa translations, but currently it's dead code. I'll
send a patch.
best,
magnus