[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] x86/ACPI: fix S3 wakeup vector mapping


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 29 Dec 2020 11:51:16 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qG8/AL35yjMCHqR4iyWD6TLIat3zqRylgKO2oXOs8sg=; b=Cv8r6M3JXMvf68j7rGDvGWI+fVeDUzN9dVYKACgdROvT4jIYKrRxvQIYfOUOVGApCMUTJbGUx4AZkX99njZO/OSafpcmlBe/cHKx/AGmFTWhDX3GsApREpMlafJQn+VeQb+te8IBo6jliTJAHN0q9LFZXdei7STI6SEA9Eo+Wl2JFXEsYxYwsFEi9tOQIMMJitn7alSqcrfVzjxzZHUI0nlQgk5+tRhPHI069kSdnYgpkAyoVPmhJJpT6SijkhLHy7nRc98jZEEx1nNmq4PON4yl81zYmCHbDOgsM0JX4To7821pB26tTlG6HCFlHGx74W2HETaH8PavfGsRKjzkUQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YQFxykOBHlQrwl8VJ29VpS/+M7KrUzCrIdDf6pNI00jFXXh+VWDVwYktqwEIsJuPkWpU27y1VbhhI1066jrYp3B8vRotuNICus1t0z2dZbd2IHEoFv7au7pUJuV1J0VqyLuHvnh6HOhjlcaK4f3+R5B9qkXcoDTgOfSquZ+aX26OAskr3txQ2F3Gv0cL8tFMDmHGwFNvnc0Kt7y3TvcWz4+ZhMZTdPwNCHMUGfoYau6GoBVe4dcVk/3Q7OnD2yzqdDtaNFwKeTRHWDaIDVr1FkZEVK7HHrP7/bgm7hYPvDZN0gFoEJQe7WykRawX5h8Eqlg/S1E0tzAK7rZ1lfCo/w==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Tue, 29 Dec 2020 10:51:30 +0000
  • Ironport-sdr: NedtSPx6ihld52GWYzZKDEfIH+4J7Rq/jzwLon1bHAlqof2PhyJwkoTyFZ5R9nCyzpJlBAy5OG 6xoEeVwmGEbru2ZgfycHLCXVomJdAcErX3i1iI6Q+XxzJSAxNcjBlPKx1CL0NqURpkFEQeSrzV jDrRN6WEfW1AUyxvgmuyQP32dKDi0s8NGAbKu1LNnoc99X1/1VVAQyvsxTVxDFWVH/x0gRETuy k7Ilecyxoz6JcNOuJGnwsxKTDMQnw/Y7YTBY9+aFju5Q7mbMYde1IqFJxDZZCrUme8NFAInmK+ HaQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Nov 23, 2020 at 01:40:12PM +0100, Jan Beulich wrote:
> Use of __acpi_map_table() here was at least close to an abuse already
> before, but it will now consistently return NULL here. Drop the layering
> violation and use set_fixmap() directly. Re-use of the ACPI fixmap area
> is hopefully going to remain "fine" for the time being.
> 
> Add checks to acpi_enter_sleep(): The vector now needs to be contained
> within a single page, but the ACPI spec requires 64-byte alignment of
> FACS anyway. Also bail if no wakeup vector was determined in the first
> place, in part as preparation for a subsequent relaxation change.
> 
> Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and 
> acpi_os_unmap_memory()")
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

See below for a comment.

> 
> --- a/xen/arch/x86/acpi/boot.c
> +++ b/xen/arch/x86/acpi/boot.c
> @@ -443,6 +443,11 @@ acpi_fadt_parse_sleep_info(struct acpi_t
>                       "FACS is shorter than ACPI spec allow: %#x",
>                       facs->length);
>  
> +     if (facs_pa % 64)
> +             printk(KERN_WARNING PREFIX
> +                     "FACS is not 64-byte aligned: %#lx",
> +                     facs_pa);
> +
>       acpi_sinfo.wakeup_vector = facs_pa + 
>               offsetof(struct acpi_table_facs, firmware_waking_vector);
>       acpi_sinfo.vector_width = 32;
> --- a/xen/arch/x86/acpi/power.c
> +++ b/xen/arch/x86/acpi/power.c
> @@ -174,17 +174,20 @@ static void acpi_sleep_prepare(u32 state
>      if ( state != ACPI_STATE_S3 )
>          return;
>  
> -    wakeup_vector_va = __acpi_map_table(
> -        acpi_sinfo.wakeup_vector, sizeof(uint64_t));
> -
>      /* TBoot will set resume vector itself (when it is safe to do so). */
>      if ( tboot_in_measured_env() )
>          return;
>  
> +    set_fixmap(FIX_ACPI_END, acpi_sinfo.wakeup_vector);
> +    wakeup_vector_va = fix_to_virt(FIX_ACPI_END) +
> +                       PAGE_OFFSET(acpi_sinfo.wakeup_vector);
> +
>      if ( acpi_sinfo.vector_width == 32 )
>          *(uint32_t *)wakeup_vector_va = bootsym_phys(wakeup_start);
>      else
>          *(uint64_t *)wakeup_vector_va = bootsym_phys(wakeup_start);
> +
> +    clear_fixmap(FIX_ACPI_END);
>  }
>  
>  static void acpi_sleep_post(u32 state) {}
> @@ -331,6 +334,12 @@ static long enter_state_helper(void *dat
>   */
>  int acpi_enter_sleep(struct xenpf_enter_acpi_sleep *sleep)
>  {
> +    if ( sleep->sleep_state == ACPI_STATE_S3 &&
> +         (!acpi_sinfo.wakeup_vector || !acpi_sinfo.vector_width ||
> +          (PAGE_OFFSET(acpi_sinfo.wakeup_vector) >
> +           PAGE_SIZE - acpi_sinfo.vector_width / 8)) )

Shouldn't this last check better be done in acpi_fadt_parse_sleep_info
and then avoid setting wakeup_vector in the first place?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.