|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v17 12/13] x86/hvm: Remove redundant save functions
On Wed, Aug 22, 2018 at 05:02:42PM +0300, Alexandru Isaila wrote:
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 4a70251..831f86b 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -740,7 +740,7 @@ void hvm_domain_destroy(struct domain *d)
> destroy_vpci_mmcfg(d);
> }
>
> -static int hvm_save_tsc_adjust_one(struct vcpu *v, hvm_domain_context_t *h)
> +static int hvm_save_tsc_adjust(struct vcpu *v, hvm_domain_context_t *h)
> {
> struct hvm_tsc_adjust ctxt = {
> .tsc_adjust = v->arch.hvm_vcpu.msr_tsc_adjust,
> @@ -749,21 +749,6 @@ static int hvm_save_tsc_adjust_one(struct vcpu *v,
> hvm_domain_context_t *h)
> return hvm_save_entry(TSC_ADJUST, v->vcpu_id, h, &ctxt);
> }
>
> -static int hvm_save_tsc_adjust(struct domain *d, hvm_domain_context_t *h)
> -{
> - struct vcpu *v;
> - int err = 0;
> -
> - for_each_vcpu ( d, v )
> - {
> - err = hvm_save_tsc_adjust_one(v, h);
> - if ( err )
> - break;
> - }
> -
> - return err;
> -}
> -
> static int hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h)
> {
> unsigned int vcpuid = hvm_load_instance(h);
> @@ -785,10 +770,9 @@ static int hvm_load_tsc_adjust(struct domain *d,
> hvm_domain_context_t *h)
> }
>
> HVM_REGISTER_SAVE_RESTORE(TSC_ADJUST, hvm_save_tsc_adjust,
> - hvm_save_tsc_adjust_one,
> hvm_load_tsc_adjust, 1, HVMSR_PER_VCPU);
>
> -static int hvm_save_cpu_ctxt_one(struct vcpu *v, hvm_domain_context_t *h)
> +static int hvm_save_cpu_ctxt(struct vcpu *v, hvm_domain_context_t *h)
> {
> struct segment_register seg;
> struct hvm_hw_cpu ctxt = {
> @@ -895,21 +879,6 @@ static int hvm_save_cpu_ctxt_one(struct vcpu *v,
> hvm_domain_context_t *h)
> return hvm_save_entry(CPU, v->vcpu_id, h, &ctxt);
> }
>
> -static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
> -{
> - struct vcpu *v;
> - int err = 0;
> -
> - for_each_vcpu ( d, v )
> - {
> - err = hvm_save_cpu_ctxt_one(v, h);
> - if ( err )
> - break;
> - }
> -
> - return err;
> -}
> -
> /* Return a string indicating the error, or NULL for valid. */
> const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
> signed int cr0_pg)
> @@ -1181,7 +1150,7 @@ static int hvm_load_cpu_ctxt(struct domain *d,
> hvm_domain_context_t *h)
> return 0;
> }
>
> -HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt, hvm_save_cpu_ctxt_one,
> +HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt,
> hvm_load_cpu_ctxt,
> 1, HVMSR_PER_VCPU);
Looks like you can fit more in the first line AFAICT.
[...]
> diff --git a/xen/arch/x86/hvm/i8254.c b/xen/arch/x86/hvm/i8254.c
> index ec77b23..e0d2255 100644
> --- a/xen/arch/x86/hvm/i8254.c
> +++ b/xen/arch/x86/hvm/i8254.c
> @@ -390,8 +390,9 @@ void pit_stop_channel0_irq(PITState *pit)
> spin_unlock(&pit->lock);
> }
>
> -static int pit_save(struct domain *d, hvm_domain_context_t *h)
> +static int pit_save(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
> PITState *pit = domain_vpit(d);
> int rc;
>
> @@ -437,7 +438,7 @@ static int pit_load(struct domain *d,
> hvm_domain_context_t *h)
> return 0;
> }
>
> -HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, NULL, pit_load, 1, HVMSR_PER_DOM);
> +HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, pit_load, 1, HVMSR_PER_DOM);
>
> void pit_reset(struct domain *d)
> {
> diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
> index 770eab7..b37275c 100644
> --- a/xen/arch/x86/hvm/irq.c
> +++ b/xen/arch/x86/hvm/irq.c
> @@ -630,8 +630,9 @@ static int __init dump_irq_info_key_init(void)
> }
> __initcall(dump_irq_info_key_init);
>
> -static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)
> +static int irq_save_pci(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
> struct hvm_irq *hvm_irq = hvm_domain_irq(d);
> unsigned int asserted, pdev, pintx;
> int rc;
> @@ -662,16 +663,18 @@ static int irq_save_pci(struct domain *d,
> hvm_domain_context_t *h)
> return rc;
> }
>
> -static int irq_save_isa(struct domain *d, hvm_domain_context_t *h)
> +static int irq_save_isa(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
const
> struct hvm_irq *hvm_irq = hvm_domain_irq(d);
>
> /* Save ISA IRQ lines */
> return ( hvm_save_entry(ISA_IRQ, 0, h, &hvm_irq->isa_irq) );
> }
>
> -static int irq_save_link(struct domain *d, hvm_domain_context_t *h)
> +static int irq_save_link(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
const
[...]
> diff --git a/xen/arch/x86/hvm/save.c b/xen/arch/x86/hvm/save.c
> index 1eb2b01..49741e0 100644
> --- a/xen/arch/x86/hvm/save.c
> +++ b/xen/arch/x86/hvm/save.c
> @@ -85,7 +85,6 @@ int arch_hvm_load(struct domain *d, struct hvm_save_header
> *hdr)
> /* List of handlers for various HVM save and restore types */
> static struct {
> hvm_save_handler save;
> - hvm_save_vcpu_handler save_one;
> hvm_load_handler load;
> const char *name;
> size_t size;
> @@ -96,7 +95,6 @@ static struct {
> void __init hvm_register_savevm(uint16_t typecode,
> const char *name,
> hvm_save_handler save_state,
> - hvm_save_vcpu_handler save_one,
> hvm_load_handler load_state,
> size_t size, int kind)
> {
> @@ -104,7 +102,6 @@ void __init hvm_register_savevm(uint16_t typecode,
> ASSERT(hvm_sr_handlers[typecode].save == NULL);
> ASSERT(hvm_sr_handlers[typecode].load == NULL);
> hvm_sr_handlers[typecode].save = save_state;
> - hvm_sr_handlers[typecode].save_one = save_one;
> hvm_sr_handlers[typecode].load = load_state;
> hvm_sr_handlers[typecode].name = name;
> hvm_sr_handlers[typecode].size = size;
> @@ -148,6 +145,9 @@ int hvm_save_one(struct domain *d, unsigned int typecode,
> unsigned int instance,
> !hvm_sr_handlers[typecode].save )
> return -EINVAL;
>
> + if ( hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU &&
> + instance >= d->max_vcpus )
> + return -ENOENT;
> ctxt.size = hvm_sr_handlers[typecode].size;
> if ( hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU )
> ctxt.size *= d->max_vcpus;
> @@ -155,7 +155,7 @@ int hvm_save_one(struct domain *d, unsigned int typecode,
> unsigned int instance,
> if ( !ctxt.data )
> return -ENOMEM;
>
> - if ( (rv = hvm_sr_handlers[typecode].save(d, &ctxt)) != 0 )
> + if ( (rv = hvm_sr_handlers[typecode].save(d->vcpu[instance], &ctxt)) !=
> 0 )
> printk(XENLOG_G_ERR "HVM%d save: failed to save type %"PRIu16"
> (%d)\n",
> d->domain_id, typecode, rv);
> else if ( rv = -ENOENT, ctxt.cur >= sizeof(*desc) )
> @@ -223,17 +223,19 @@ int hvm_save(struct domain *d, hvm_domain_context_t *h)
> for ( i = 0; i <= HVM_SAVE_CODE_MAX; i++ )
> {
> struct vcpu *v;
> - hvm_save_vcpu_handler save_one_handler = hvm_sr_handlers[i].save_one;
> - hvm_save_handler handler = hvm_sr_handlers[i].save;;
> + hvm_save_handler handler = hvm_sr_handlers[i].save;
>
> - if ( save_one_handler )
> + if ( !handler )
> + continue;
> +
> + if ( hvm_sr_handlers[i].kind == HVMSR_PER_VCPU )
> {
> for_each_vcpu ( d, v )
> {
> printk(XENLOG_G_INFO "HVM %pv save: %s\n",
> v, hvm_sr_handlers[i].name);
>
> - if ( save_one_handler(v, h) != 0 )
> + if ( handler(v, h) != 0 )
> {
> printk(XENLOG_G_ERR
> "HVM %pv save: failed to save type %"PRIu16"\n",
> @@ -242,15 +244,15 @@ int hvm_save(struct domain *d, hvm_domain_context_t *h)
> }
> }
> }
> - else if ( handler )
> + else
> {
> - printk(XENLOG_G_INFO "HVM%d save: %s\n",
> + printk(XENLOG_G_INFO "HVM d%d save: %s\n",
> d->domain_id, hvm_sr_handlers[i].name);
>
> - if ( handler(d, h) != 0 )
> + if ( handler(d->vcpu[0], h) != 0 )
> {
> printk(XENLOG_G_ERR
> - "HVM%d save: failed to save type %"PRIu16"\n",
> + "HVM d%d save: failed to save type %"PRIu16"\n",
This looks like an unrelated change.
> d->domain_id, i);
> return -ENODATA;
> }
> diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
> index 66f54e4..86d02cf 100644
> --- a/xen/arch/x86/hvm/vioapic.c
> +++ b/xen/arch/x86/hvm/vioapic.c
> @@ -569,8 +569,9 @@ int vioapic_get_trigger_mode(const struct domain *d,
> unsigned int gsi)
> return vioapic->redirtbl[pin].fields.trig_mode;
> }
>
> -static int ioapic_save(struct domain *d, hvm_domain_context_t *h)
> +static int ioapic_save(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
const
> struct hvm_vioapic *s;
>
> if ( !has_vioapic(d) )
> @@ -601,7 +602,7 @@ static int ioapic_load(struct domain *d,
> hvm_domain_context_t *h)
> return hvm_load_entry(IOAPIC, h, &s->domU);
> }
>
> -HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, NULL, ioapic_load, 1,
> HVMSR_PER_DOM);
> +HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1,
> HVMSR_PER_DOM);
>
> void vioapic_reset(struct domain *d)
> {
> diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
> index 268ccce..cc37ab4 100644
> --- a/xen/arch/x86/hvm/viridian.c
> +++ b/xen/arch/x86/hvm/viridian.c
> @@ -990,8 +990,9 @@ out:
> return HVM_HCALL_completed;
> }
>
> -static int viridian_save_domain_ctxt(struct domain *d, hvm_domain_context_t
> *h)
> +static int viridian_save_domain_ctxt(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
const
[...]
> diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c
> index ca9b4cb..bad5066 100644
> --- a/xen/arch/x86/hvm/vpic.c
> +++ b/xen/arch/x86/hvm/vpic.c
> @@ -371,8 +371,9 @@ static int vpic_intercept_elcr_io(
> return X86EMUL_OKAY;
> }
>
> -static int vpic_save(struct domain *d, hvm_domain_context_t *h)
> +static int vpic_save(struct vcpu *v, hvm_domain_context_t *h)
> {
> + struct domain *d = v->domain;
const
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |