On Tue, Nov 25, 2025 at 01:08:52PM +0100, Magnus Kulke wrote:
> The removed parameters are remnants of a prior attempt to optimize
> gva=>gpa translation. Currently there is only one call site and it's
> not using it. So we can remove it as dead code.
> 
> Signed-off-by: Magnus Kulke <[email protected]>
> ---
>  target/i386/mshv/mshv-cpu.c | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
> index 1c3db02188..03ef085d5e 100644
> --- a/target/i386/mshv/mshv-cpu.c
> +++ b/target/i386/mshv/mshv-cpu.c
> @@ -1189,7 +1189,7 @@ static int handle_unmapped_mem(int vm_fd, CPUState *cpu,
>      remap_result = mshv_remap_overlap_region(vm_fd, gpa);
>      *exit_reason = MshvVmExitIgnore;
>  
> -    switch (remap_result) {
> +   switch (remap_result) {

This indentation looks off.

With this issue fixed:

Reviewed-by: Wei Liu <[email protected]>

>      case MshvRemapNoMapping:
>          /* if we didn't find a mapping, it is probably mmio */
>          return handle_mmio(cpu, msg, exit_reason);
> @@ -1374,23 +1374,19 @@ static int read_memory(const CPUState *cpu, uint64_t 
> initial_gva,
>      return 0;
>  }
>  
> -static int write_memory(const CPUState *cpu, uint64_t initial_gva,
> -                        uint64_t initial_gpa, uint64_t gva, const uint8_t 
> *data,
> +static int write_memory(const CPUState *cpu, uint64_t gva, const uint8_t 
> *data,
>                          size_t len)
>  {
>      int ret;
>      uint64_t gpa, flags;
>  
> -    if (gva == initial_gva) {
> -        gpa = initial_gpa;
> -    } else {
> -        flags = HV_TRANSLATE_GVA_VALIDATE_WRITE;
> -        ret = translate_gva(cpu, gva, &gpa, flags);
> -        if (ret < 0) {
> -            error_report("failed to translate gva to gpa");
> -            return -1;
> -        }
> +    flags = HV_TRANSLATE_GVA_VALIDATE_WRITE;
> +    ret = translate_gva(cpu, gva, &gpa, flags);
> +    if (ret < 0) {
> +        error_report("failed to translate gva to gpa");
> +        return -1;
>      }
> +
>      ret = mshv_guest_mem_write(gpa, data, len, false);

Not entirely related to this, but you should be careful with cross-page
accesses in these functions.

Wei

Reply via email to