From 35dfadc98ed05705b1c302d6e9bbd52f6c2cc93e Mon Sep 17 00:00:00 2001 From: Yuan Liu Date: Thu, 28 Feb 2019 15:35:13 +0800 Subject: [PATCH] dm: check SCI_EN bit of pm1_control before trigger SCI Followed ACPI spec 4.8.2.5, if SCI_EN is set, the interrupt will be routed to SCI interrupt logic. If SCI_EN is not set, the interrupt will be routed to SMI interrupt logic. ACRN does not support SMI for now, so check SCI_EN before trigger SCI. Tracked-On: #2560 Signed-off-by: Yuan Liu Acked-by: Yu Wang --- devicemodel/arch/x86/pm.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/devicemodel/arch/x86/pm.c b/devicemodel/arch/x86/pm.c index 52115900e..f960ed0af 100644 --- a/devicemodel/arch/x86/pm.c +++ b/devicemodel/arch/x86/pm.c @@ -137,11 +137,31 @@ static uint16_t pm1_enable, pm1_status; #define PM1_SLPBTN_EN 0x0200 #define PM1_RTC_EN 0x0400 +/* + * Power Management 1 Control Register + * + * This is mostly unimplemented except that we wish to handle writes that + * set SPL_EN to handle S5 (soft power off). + */ +static uint16_t pm1_control; + +#define PM1_SCI_EN 0x0001 +#define PM1_SLP_TYP 0x1c00 +#define PM1_SLP_EN 0x2000 +#define PM1_ALWAYS_ZERO 0xc003 + static void sci_update(struct vmctx *ctx) { int need_sci; + /* + * Followed ACPI spec, should trigger SMI if SCI_EN is zero. + * Return directly due to ACRN do not support SMI so far. + */ + if (!(pm1_control & PM1_SCI_EN)) + return; + /* See if the SCI should be active or not. */ need_sci = 0; if ((pm1_enable & PM1_TMR_EN) && (pm1_status & PM1_TMR_STS)) @@ -251,19 +271,6 @@ input_event0_handler(int fd, enum ev_type type, void *arg) power_button_press_emulation(arg); } -/* - * Power Management 1 Control Register - * - * This is mostly unimplemented except that we wish to handle writes that - * set SPL_EN to handle S5 (soft power off). - */ -static uint16_t pm1_control; - -#define PM1_SCI_EN 0x0001 -#define PM1_SLP_TYP 0x1c00 -#define PM1_SLP_EN 0x2000 -#define PM1_ALWAYS_ZERO 0xc003 - static int pm1_control_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, uint32_t *eax, void *arg)