From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Wroblewski Subject: [PATCH v4] Fix acpi_dmar_zap/reinstate() (fixes S3 regression) Date: Wed, 23 Jan 2013 10:02:55 +0100 Message-ID: <50FFA73F.8030301@citrix.com> References: <50FE8126.8080005@citrix.com> <50FE9B1802000078000B84A1@nat28.tlf.novell.com> <50FEAFE4.1030303@citrix.com> <50FEC46B02000078000B8622@nat28.tlf.novell.com> <50FECACA.7020809@citrix.com> <50FFB1C102000078000B8915@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070508000805000202000805" Return-path: In-Reply-To: <50FFB1C102000078000B8915@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --------------070508000805000202000805 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit On 23/01/13 09:47, Jan Beulich wrote: > This looks much better; I'll slightly edit it before committing > though, so please double check the result. > > I just noticed I made a mistake calculating the number of pages to map, which should be just PFN_UP(dmar_len) (although in practice both calculations ten to yield 1 page anyway); but resubmiting v4 with that fixed Signed-off-by: Tomasz Wroblewski --------------070508000805000202000805 Content-Type: text/x-patch; name="fix-dmar-zap-reinstate-v4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix-dmar-zap-reinstate-v4.patch" diff -r 4b476378fc35 xen/drivers/acpi/tables/tbxface.c --- a/xen/drivers/acpi/tables/tbxface.c Mon Jan 21 17:03:10 2013 +0000 +++ b/xen/drivers/acpi/tables/tbxface.c Wed Jan 23 08:58:43 2013 +0000 @@ -205,3 +205,44 @@ return (AE_NOT_FOUND); } + +/******************************************************************************* + * + * FUNCTION: acpi_get_table_physical_location + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * out_addr - Where the table's physical address is returned + * out_len - Where the length of table is returned + * + * RETURN: Status, pointer and length of table + * + * DESCRIPTION: Finds physical address and length of ACPI table + * + *****************************************************************************/ +acpi_status __init +acpi_get_table_physical_location(char *signature, + acpi_native_uint instance, + acpi_physical_address *out_addr, u32 *out_len) +{ + acpi_native_uint i; + acpi_native_uint j; + + if (!signature || !out_addr || !out_len) { + return (AE_BAD_PARAMETER); + } + + for (i = 0, j=0; i < acpi_gbl_root_table_list.count; i++) { + if (!ACPI_COMPARE_NAME(&(acpi_gbl_root_table_list.tables[i].signature), signature)) { + continue; + } + if (++j < instance) { + continue; + } + *out_addr = acpi_gbl_root_table_list.tables[i].address; + *out_len = acpi_gbl_root_table_list.tables[i].length; + return AE_OK; + } + + return AE_NOT_FOUND; +} diff -r 4b476378fc35 xen/drivers/passthrough/vtd/dmar.c --- a/xen/drivers/passthrough/vtd/dmar.c Mon Jan 21 17:03:10 2013 +0000 +++ b/xen/drivers/passthrough/vtd/dmar.c Wed Jan 23 08:58:43 2013 +0000 @@ -823,7 +823,17 @@ int __init acpi_dmar_init(void) { - acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_table); + acpi_physical_address dmar_addr; + u32 dmar_len; + if ( !acpi_get_table_physical_location( + ACPI_SIG_DMAR, 0, &dmar_addr, &dmar_len) ) + { + map_pages_to_xen((unsigned long)__va(dmar_addr), PFN_DOWN(dmar_addr), + PFN_UP(dmar_len), + PAGE_HYPERVISOR); + dmar_table = (struct acpi_table_header*) __va(dmar_addr); + } + return parse_dmar_table(acpi_parse_dmar); } diff -r 4b476378fc35 xen/include/acpi/acpixf.h --- a/xen/include/acpi/acpixf.h Mon Jan 21 17:03:10 2013 +0000 +++ b/xen/include/acpi/acpixf.h Wed Jan 23 08:58:43 2013 +0000 @@ -77,6 +77,10 @@ acpi_get_table(acpi_string signature, acpi_native_uint instance, struct acpi_table_header **out_table); +acpi_status +acpi_get_table_physical_location(char *signature, + acpi_native_uint instance, + acpi_physical_address *out_addr, u32 *out_len); /* * Namespace and name interfaces */ --------------070508000805000202000805 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------070508000805000202000805--