From patchwork Mon Mar 23 10:17:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11452615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A0FB6CA for ; Mon, 23 Mar 2020 10:19:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55E6F20409 for ; Mon, 23 Mar 2020 10:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Dew8tMPs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55E6F20409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGK9S-0007Z1-Tq; Mon, 23 Mar 2020 10:17:46 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGK9S-0007Ym-CV for xen-devel@lists.xenproject.org; Mon, 23 Mar 2020 10:17:46 +0000 X-Inumbo-ID: 855c6ce6-6cef-11ea-a6c1-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 855c6ce6-6cef-11ea-a6c1-bc764e2007e4; Mon, 23 Mar 2020 10:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584958658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DhcDOqjAEEu8+UEOwRSVuIVRyg3CjwPAxqeTQgZP7/U=; b=Dew8tMPsWXcSdsymQhlFlnlXW9RaSNf9F+fXiWXN9A1e6a+FRjf6rvoy NHpZ9wf9phQRSUQADX8JuVJ3fbxOQF9Ea0G5SgiPRVjkYfchd++TDjBOT Bn84lsnAOuHTS9bGPyR7KOo5dLGcWH9OJEmNR5inkyttEPzGGXaxtt+/D k=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: HW6sIBdcxZYmlcXwI557dXTUPzvU5cIlXgQugV2OxqjoXqd6pH6+nyqvdkPH7mIztXSFfzDCns dF3TJB9w7xfxE4ak5eqlTIS5Uhf5I+rRNdvJUf0oS0Ex36B+1kWG3eVKYkKL9lrvdePbc5Snz0 odsdl9QlG1qAQdT81dveayUl4kxO7gq23486mfmEUcRYEOiveGhsj4nqM/Owm7SlzDRdBec+nz aDDs1AESKw5vl5XWHLGXG0Bbv+tesgBwcAKoCFZYvVPCzGih5EPRi050HAvrGuaiN/jW51gKea GYE= X-SBRS: 2.7 X-MesageID: 15099733 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,296,1580792400"; d="scan'208";a="15099733" From: Andrew Cooper To: Xen-devel Date: Mon, 23 Mar 2020 10:17:19 +0000 Message-ID: <20200323101724.15655-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200323101724.15655-1-andrew.cooper3@citrix.com> References: <20200323101724.15655-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/7] x86/ucode/intel: Adjust microcode_sanity_check() to not take void * X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" microcode_sanity_check()'s callers actually call it with a mixture of microcode_intel and microcode_header_intel pointers, which is fragile. Rework it to take struct microcode_intel *, which in turn requires microcode_update_match()'s type to be altered. No functional change - compiled binary is identical. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/cpu/microcode/intel.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcode/intel.c index f26511da98..f0beefe1bb 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -119,9 +119,9 @@ static int collect_cpu_info(struct cpu_signature *csig) return 0; } -static int microcode_sanity_check(const void *mc) +static int microcode_sanity_check(const struct microcode_intel *mc) { - const struct microcode_header_intel *mc_header = mc; + const struct microcode_header_intel *mc_header = &mc->hdr; const struct extended_sigtable *ext_header = NULL; const struct extended_signature *ext_sig; unsigned long total_size, data_size, ext_table_size; @@ -153,7 +153,7 @@ static int microcode_sanity_check(const void *mc) "Small exttable size in microcode data file\n"); return -EINVAL; } - ext_header = mc + MC_HEADER_SIZE + data_size; + ext_header = (void *)mc + MC_HEADER_SIZE + data_size; if ( ext_table_size != exttable_size(ext_header) ) { printk(KERN_ERR "microcode: error! " @@ -211,8 +211,9 @@ static int microcode_sanity_check(const void *mc) /* Check an update against the CPU signature and current update revision */ static enum microcode_match_result microcode_update_match( - const struct microcode_header_intel *mc_header) + const struct microcode_intel *mc) { + const struct microcode_header_intel *mc_header = &mc->hdr; const struct extended_sigtable *ext_header; const struct extended_signature *ext_sig; unsigned int i; @@ -223,7 +224,7 @@ static enum microcode_match_result microcode_update_match( unsigned long data_size = get_datasize(mc_header); const void *end = (const void *)mc_header + get_totalsize(mc_header); - ASSERT(!microcode_sanity_check(mc_header)); + ASSERT(!microcode_sanity_check(mc)); if ( sigmatch(sig, mc_header->sig, pf, mc_header->pf) ) return (mc_header->rev > rev) ? NEW_UCODE : OLD_UCODE; @@ -249,7 +250,7 @@ static bool match_cpu(const struct microcode_patch *patch) if ( !patch ) return false; - return microcode_update_match(&patch->mc_intel->hdr) == NEW_UCODE; + return microcode_update_match(patch->mc_intel) == NEW_UCODE; } static void free_patch(struct microcode_patch *patch) @@ -268,8 +269,8 @@ static enum microcode_match_result compare_patch( * Both patches to compare are supposed to be applicable to local CPU. * Just compare the revision number. */ - ASSERT(microcode_update_match(&old->mc_intel->hdr) != MIS_UCODE); - ASSERT(microcode_update_match(&new->mc_intel->hdr) != MIS_UCODE); + ASSERT(microcode_update_match(old->mc_intel) != MIS_UCODE); + ASSERT(microcode_update_match(new->mc_intel) != MIS_UCODE); return (new->mc_intel->hdr.rev > old->mc_intel->hdr.rev) ? NEW_UCODE : OLD_UCODE; @@ -367,7 +368,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf, * If the new update covers current CPU, compare updates and store the * one with higher revision. */ - if ( (microcode_update_match(&mc->hdr) != MIS_UCODE) && + if ( (microcode_update_match(mc) != MIS_UCODE) && (!saved || (mc->hdr.rev > saved->hdr.rev)) ) { xfree(saved);