[PATCH 06/11] xen/platform_op: Wrap around XENPF_enter_acpi_sleep

Jiqian Chen posted 11 patches 3 months, 1 week ago
[PATCH 06/11] xen/platform_op: Wrap around XENPF_enter_acpi_sleep
Posted by Jiqian Chen 3 months, 1 week ago
Wrap call stack functions of XENPF_enter_acpi_sleep:
acpi_enter_sleep
	enter_state_helper
		enter_state
			freeze_domains
			scheduler_disable
				schedule_dummy
			disable_nonboot_cpus
			acpi_sleep_prepare
			device_power_down
				console_suspend
					console_steal
					suspend_steal_fn
					serial_suspend
				i8259A_suspend
					save_ELCR
				ioapic_suspend
				iommu_suspend
				lapic_suspend
			device_power_up
				lapic_resume
					resume_x2apic
				iommu_resume
				ioapic_resume
				i8259A_resume
				console_resume
					serial_resume
					console_giveback
			tboot_s3_resume
			tboot_s3_error
			acpi_sleep_post
			enable_nonboot_cpus
			thaw_domains

Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
---
cc: Jan Beulich <jbeulich@suse.com>
cc: Andrew Cooper <andrew.cooper3@citrix.com>
cc: "Roger Pau Monné" <roger.pau@citrix.com>
cc: Anthony PERARD <anthony.perard@vates.tech>
cc: Michal Orzel <michal.orzel@amd.com>
cc: Julien Grall <julien@xen.org>
cc: Stefano Stabellini <sstabellini@kernel.org>
cc: Lukasz Hawrylko <lukasz@hawrylko.pl>
cc: "Daniel P. Smith" <dpsmith@apertussolutions.com>
cc: "Mateusz Mówka" <mateusz.mowka@intel.com>
cc: Dario Faggioli <dfaggioli@suse.com>
cc: Juergen Gross <jgross@suse.com>
cc: George Dunlap <gwd@xenproject.org>
---
 xen/arch/x86/acpi/power.c       | 4 ++++
 xen/arch/x86/apic.c             | 4 ++++
 xen/arch/x86/i8259.c            | 2 ++
 xen/arch/x86/io_apic.c          | 2 ++
 xen/arch/x86/tboot.c            | 2 ++
 xen/common/cpu.c                | 2 ++
 xen/common/domain.c             | 4 ++--
 xen/common/sched/core.c         | 2 ++
 xen/drivers/char/console.c      | 6 ++++--
 xen/drivers/passthrough/iommu.c | 2 ++
 10 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
index 2ac162c997fe..a0c76a146793 100644
--- a/xen/arch/x86/acpi/power.c
+++ b/xen/arch/x86/acpi/power.c
@@ -66,7 +66,9 @@ static int __init cf_check parse_acpi_sleep(const char *s)
 }
 custom_param("acpi_sleep", parse_acpi_sleep);
 
+#ifdef CONFIG_PLATFORM_OP
 static DEFINE_SPINLOCK(pm_lock);
+#endif
 
 struct acpi_sleep_info acpi_sinfo;
 
@@ -84,6 +86,7 @@ enum dev_power_saved
     SAVED_ALL,
 };
 
+#ifdef CONFIG_PLATFORM_OP
 static int device_power_down(void)
 {
     if ( console_suspend() )
@@ -376,6 +379,7 @@ int acpi_enter_sleep(const struct xenpf_enter_acpi_sleep *sleep)
 
     return continue_hypercall_on_cpu(0, enter_state_helper, &acpi_sinfo);
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 static int acpi_get_wake_status(void)
 {
diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index 0fd8bdba7067..1ee9ee120cb2 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -479,12 +479,14 @@ static void __enable_x2apic(void)
     }
 }
 
+#ifdef CONFIG_PLATFORM_OP
 static void resume_x2apic(void)
 {
     if ( iommu_x2apic_enabled )
         iommu_enable_x2apic();
     __enable_x2apic();
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 void setup_local_APIC(bool bsp)
 {
@@ -635,6 +637,7 @@ void setup_local_APIC(bool bsp)
     apic_pm_activate();
 }
 
+#ifdef CONFIG_PLATFORM_OP
 int lapic_suspend(void)
 {
     unsigned long flags;
@@ -727,6 +730,7 @@ int lapic_resume(void)
     local_irq_restore(flags);
     return 0;
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 
 /*
diff --git a/xen/arch/x86/i8259.c b/xen/arch/x86/i8259.c
index 5c7e21a7515c..8a7c89f3827e 100644
--- a/xen/arch/x86/i8259.c
+++ b/xen/arch/x86/i8259.c
@@ -255,6 +255,7 @@ static bool _mask_and_ack_8259A_irq(unsigned int irq)
     return is_real_irq;
 }
 
+#ifdef CONFIG_PLATFORM_OP
 static char irq_trigger[2];
 /**
  * ELCR registers (0x4d0, 0x4d1) control edge/level of IRQ
@@ -284,6 +285,7 @@ int i8259A_suspend(void)
     save_ELCR(irq_trigger);
     return 0;
 }
+#endif
 
 void init_8259A(int auto_eoi)
 {
diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 1816e1c0b9f4..117ceeec633a 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2174,6 +2174,7 @@ void __init setup_IO_APIC(void)
     register_keyhandler('z', _print_IO_APIC_keyhandler, "dump IOAPIC info", 1);
 }
 
+#ifdef CONFIG_PLATFORM_OP
 void ioapic_suspend(void)
 {
     struct IO_APIC_route_entry *entry = ioapic_pm_state;
@@ -2211,6 +2212,7 @@ void ioapic_resume(void)
     }
     spin_unlock_irqrestore(&ioapic_lock, flags);
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 /* --------------------------------------------------------------------------
                           ACPI-based IOAPIC Configuration
diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
index d5db60d335e3..ee142759acda 100644
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -471,6 +471,7 @@ int __init cf_check tboot_parse_dmar_table(acpi_table_handler dmar_handler)
 
 static vmac_t orig_mac, resume_mac;
 
+#ifdef CONFIG_PLATFORM_OP
 int tboot_s3_resume(void)
 {
     if ( !tboot_in_measured_env() )
@@ -512,6 +513,7 @@ void tboot_s3_error(int error)
     printk("MAC for %s after S3 is: 0x%08"PRIx64"\n", what, resume_mac);
     panic("Memory integrity was lost on resume (%d)\n", error);
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 int tboot_wake_ap(int apicid, unsigned long sipi_vec)
 {
diff --git a/xen/common/cpu.c b/xen/common/cpu.c
index f09af0444b6a..32e803d65da3 100644
--- a/xen/common/cpu.c
+++ b/xen/common/cpu.c
@@ -190,6 +190,7 @@ void notify_cpu_starting(unsigned int cpu)
     cpu_notifier_call_chain(cpu, CPU_STARTING, NULL, true);
 }
 
+#ifdef CONFIG_PLATFORM_OP
 static cpumask_t frozen_cpus;
 
 int disable_nonboot_cpus(void)
@@ -247,3 +248,4 @@ void enable_nonboot_cpus(void)
 
     cpumask_clear(&frozen_cpus);
 }
+#endif /* CONFIG_PLATFORM_OP */
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 303c338ef293..5eeb3efdfad0 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2411,7 +2411,7 @@ domid_t get_initial_domain_id(void)
     return 0;
 }
 
-#ifdef CONFIG_SYSTEM_SUSPEND
+#if defined(CONFIG_SYSTEM_SUSPEND) && defined(CONFIG_PLATFORM_OP)
 
 void freeze_domains(void)
 {
@@ -2438,7 +2438,7 @@ void thaw_domains(void)
     rcu_read_unlock(&domlist_read_lock);
 }
 
-#endif /* CONFIG_SYSTEM_SUSPEND */
+#endif /* CONFIG_SYSTEM_SUSPEND and CONFIG_PLATFORM_OP*/
 
 /*
  * Local variables:
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index ea95dea65a58..2ab86e6227df 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -2967,6 +2967,7 @@ const cpumask_t *sched_get_opt_cpumask(enum sched_gran opt, unsigned int cpu)
     return mask;
 }
 
+#ifdef CONFIG_PLATFORM_OP
 static void cf_check schedule_dummy(void)
 {
     sched_tasklet_check_cpu(smp_processor_id());
@@ -2978,6 +2979,7 @@ void scheduler_disable(void)
     open_softirq(SCHEDULE_SOFTIRQ, schedule_dummy);
     open_softirq(SCHED_SLAVE_SOFTIRQ, schedule_dummy);
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 void scheduler_enable(void)
 {
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index c5afac9f7259..83da6f095aff 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -428,6 +428,7 @@ static unsigned int serial_rx_cons, serial_rx_prod;
 
 static void (*serial_steal_fn)(const char *str, size_t nr) = early_puts;
 
+#ifdef CONFIG_PLATFORM_OP
 int console_steal(int handle, void (*fn)(const char *str, size_t nr))
 {
     if ( (handle == -1) || (handle != sercon_handle) )
@@ -445,6 +446,7 @@ void console_giveback(int id)
     if ( id == 1 )
         serial_steal_fn = NULL;
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 void console_serial_puts(const char *s, size_t nr)
 {
@@ -1367,7 +1369,7 @@ void panic(const char *fmt, ...)
         machine_restart(5000);
 }
 
-#ifdef CONFIG_SYSTEM_SUSPEND
+#if defined(CONFIG_SYSTEM_SUSPEND) && defined(CONFIG_PLATFORM_OP)
 
 /*
  * **************************************************************
@@ -1392,7 +1394,7 @@ int console_resume(void)
     return 0;
 }
 
-#endif /* CONFIG_SYSTEM_SUSPEND */
+#endif /* CONFIG_SYSTEM_SUSPEND and CONFIG_PLATFORM_OP*/
 
 /*
  * Local variables:
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index c9425d6971cb..0a0080452721 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -611,6 +611,7 @@ int __init iommu_setup(void)
     return rc;
 }
 
+#ifdef CONFIG_PLATFORM_OP
 int iommu_suspend(void)
 {
     if ( iommu_enabled )
@@ -624,6 +625,7 @@ void iommu_resume(void)
     if ( iommu_enabled )
         iommu_vcall(iommu_get_ops(), resume);
 }
+#endif /* CONFIG_PLATFORM_OP */
 
 int iommu_do_domctl(
     struct xen_domctl *domctl, struct domain *d,
-- 
2.34.1