From: "Jan Beulich" Subject: [PATCH 2/2] x86/tboot: simplify DMAR table copying Date: Wed, 18 Feb 2015 09:03:43 +0000 Message-ID: <54E4637F0200007800060EE5@mail.emea.novell.com> References: <54E461B50200007800060ED5@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF2C74F7F.2__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YO0Xu-0007NM-LV for xen-devel@lists.xenproject.org; Wed, 18 Feb 2015 09:03:50 +0000 In-Reply-To: <54E461B50200007800060ED5@mail.emea.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: xen-devel Cc: Andrew Cooper , Joseph Cihula , Gang Wei , Shane Wang List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartF2C74F7F.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline There's no need for more than one variable, no need for casts, and no point in using the type-safe xmalloc_array() here. Signed-off-by: Jan Beulich --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -435,13 +435,12 @@ int __init tboot_protect_mem_regions(voi =20 int __init tboot_parse_dmar_table(acpi_table_handler dmar_handler) { - struct acpi_table_header *dmar_table; int rc; uint64_t size; uint32_t dmar_table_length; unsigned long pa; sinit_mle_data_t sinit_mle_data; - unsigned char *dmar_table_raw; + void *dmar_table; =20 if ( !tboot_in_measured_env() ) return acpi_table_parse(ACPI_SIG_DMAR, dmar_handler); @@ -474,13 +473,12 @@ int __init tboot_parse_dmar_table(acpi_t tboot_copy_memory((unsigned char *)&dmar_table_length, sizeof(dmar_table_length), pa + sizeof(char) * ACPI_NAME_SIZE); - dmar_table_raw =3D xmalloc_array(unsigned char, dmar_table_length); - tboot_copy_memory(dmar_table_raw, dmar_table_length, pa); - dmar_table =3D (struct acpi_table_header *)dmar_table_raw; + dmar_table =3D xmalloc_bytes(dmar_table_length); + tboot_copy_memory(dmar_table, dmar_table_length, pa); __set_fixmap(FIX_TBOOT_MAP_ADDRESS, 0, 0); =20 rc =3D dmar_handler(dmar_table); - xfree(dmar_table_raw); + xfree(dmar_table); =20 /* acpi_parse_dmar() zaps APCI DMAR signature in TXT heap table */ /* but dom0 will read real table, so must zap it there too */ --=__PartF2C74F7F.2__= Content-Type: text/plain; name="x86-tboot-dmar-table.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-tboot-dmar-table.patch" x86/tboot: simplify DMAR table copying=0A=0AThere's no need for more than = one variable, no need for casts, and no=0Apoint in using the type-safe = xmalloc_array() here.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/tboot.c=0A+++ b/xen/arch/x86/tboot.c=0A@@ -435,13 = +435,12 @@ int __init tboot_protect_mem_regions(voi=0A =0A int __init = tboot_parse_dmar_table(acpi_table_handler dmar_handler)=0A {=0A- struct = acpi_table_header *dmar_table;=0A int rc;=0A uint64_t size;=0A = uint32_t dmar_table_length;=0A unsigned long pa;=0A sinit_mle_data_= t sinit_mle_data;=0A- unsigned char *dmar_table_raw;=0A+ void = *dmar_table;=0A =0A if ( !tboot_in_measured_env() )=0A return = acpi_table_parse(ACPI_SIG_DMAR, dmar_handler);=0A@@ -474,13 +473,12 @@ int = __init tboot_parse_dmar_table(acpi_t=0A tboot_copy_memory((unsigned = char *)&dmar_table_length,=0A sizeof(dmar_table_lengt= h),=0A pa + sizeof(char) * ACPI_NAME_SIZE);=0A- = dmar_table_raw =3D xmalloc_array(unsigned char, dmar_table_length);=0A- = tboot_copy_memory(dmar_table_raw, dmar_table_length, pa);=0A- dmar_table= =3D (struct acpi_table_header *)dmar_table_raw;=0A+ dmar_table =3D = xmalloc_bytes(dmar_table_length);=0A+ tboot_copy_memory(dmar_table, = dmar_table_length, pa);=0A __set_fixmap(FIX_TBOOT_MAP_ADDRESS, 0, = 0);=0A =0A rc =3D dmar_handler(dmar_table);=0A- xfree(dmar_table_raw= );=0A+ xfree(dmar_table);=0A =0A /* acpi_parse_dmar() zaps APCI = DMAR signature in TXT heap table */=0A /* but dom0 will read real = table, so must zap it there too */=0A --=__PartF2C74F7F.2__= 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 --=__PartF2C74F7F.2__=--