[PATCH kvmtool 11/21] hw/rtc: Switch to new trap handler

Alexandru Elisei alexandru.elisei at arm.com
Fri Feb 12 07:02:10 EST 2021


Hi Andre,

On 12/10/20 2:28 PM, Andre Przywara wrote:
> Now that the RTC device has a trap handler adhering to the MMIO fault
> handler prototype, let's switch over to the joint registration routine.
>
> This allows us to get rid of the ioport shim routines.
>
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>
> ---
>  hw/rtc.c | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
>
> diff --git a/hw/rtc.c b/hw/rtc.c
> index 664d4cb0..ee4c9102 100644
> --- a/hw/rtc.c
> +++ b/hw/rtc.c
> @@ -120,23 +120,6 @@ static void cmos_ram_io(struct kvm_cpu *vcpu, u64 addr, u8 *data,
>  	}
>  }
>  
> -static bool cmos_ram_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void *data, int size)
> -{
> -	cmos_ram_io(vcpu, port, data, size, false, NULL);
> -	return true;
> -}
> -
> -static bool cmos_ram_out(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void *data, int size)
> -{
> -	cmos_ram_io(vcpu, port, data, size, true, NULL);
> -	return true;
> -}
> -
> -static struct ioport_operations cmos_ram_ioport_ops = {
> -	.io_out		= cmos_ram_out,
> -	.io_in		= cmos_ram_in,
> -};
> -
>  #ifdef CONFIG_HAS_LIBFDT
>  static void generate_rtc_fdt_node(void *fdt,
>  				  struct device_header *dev_hdr,
> @@ -169,7 +152,7 @@ int rtc__init(struct kvm *kvm)
>  		return r;
>  
>  	/* PORT 0070-007F - CMOS RAM/RTC (REAL TIME CLOCK) */
> -	r = ioport__register(kvm, 0x0070, &cmos_ram_ioport_ops, 2, NULL);
> +	r = kvm__register_pio(kvm, 0x0070, 2, cmos_ram_io, NULL);
>  	if (r < 0)
>  		goto out_device;
>  
> @@ -188,7 +171,7 @@ dev_init(rtc__init);
>  int rtc__exit(struct kvm *kvm)
>  {
>  	/* PORT 0070-007F - CMOS RAM/RTC (REAL TIME CLOCK) */
> -	ioport__unregister(kvm, 0x0070);
> +	kvm__deregister_pio(kvm, 0x0070);
>  
>  	return 0;
>  }

Looks good:

Reviewed-by: Alexandru Elisei <alexandru.elisei at arm.com>

Thanks,
Alex



More information about the linux-arm-kernel mailing list