From nobody Fri Apr 26 14:55:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1584739554; cv=none; d=zohomail.com; s=zohoarc; b=c0EaCDSuJUoim4LLDvJ57ZMMqqPibVU7iVCJMeC0nveEeED0aLa6YCvj5f9F25yqH3bo0sTHi53E8cyogktVy9jKlFKjPLci4LhOkkJvZuH07U2UHxy4mwrERl/JBqaErdcb1sArl8DPpaNs+skRFHmWY8t+W1z2CMRNA70boDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584739554; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t8t9yytoOZW4ri0k+F4vk+hi0KFq2UqejYR+/ppcq9Q=; b=FPqwEepY3Gi1hOUblkSWFymBHcqPch7Ky44ohT76BC8lpXin3xokAf/6GgzYuCXOeuBsO9oXhqXWkB8fWODbcKntPr09g6aGtJxfoEo4UnwRrFxbAbkfks+j+XMbQLTslAUv7R/yQEHL46ZohFNXNoAJqtpFyaM/X8R/KhOs6pE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584739554502165.69216335508247; Fri, 20 Mar 2020 14:25:54 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8c-0003tQ-Ou; Fri, 20 Mar 2020 21:25:06 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8b-0003tA-8O for xen-devel@lists.xenproject.org; Fri, 20 Mar 2020 21:25:05 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 40a20f5e-6af1-11ea-be18-12813bfff9fa; Fri, 20 Mar 2020 21:25:00 +0000 (UTC) X-Inumbo-ID: 40a20f5e-6af1-11ea-be18-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584739500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gRxI7Oc4Wp+Qk0hR4RDsw2VmblvMSH/qTYnP7wNUnfc=; b=eEIlIbuvrE6uH1T3FoOjHy/rSdAQYlMuo4kuFIF3rVl+h9+6VAtG0Wl1 aU4xuQzS4okpn3dI22BSSI82HEZnBxkWygMb5xkseV2R9VkeSzD6FE6Ad ROWjmHdJ4IPv00cC/g2O84Hw1sEHJjoIimyyjVIMEdN/TNl4q2zlfzItn Q=; Authentication-Results: esa5.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: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: MB9IwGlG5PhaooFKrO4v/o/Rlk7htYlTa13v3F/pdJfFA5wsxypsY723eH1pdUiQ42QWcf8v25 LekmDdYiZ97KueKGcV3VepxlZC3DnwIisaHstyBkPgG0sIUVTBynNp6ygg3PxDP/qv+nW5MlaE F1USN1zk4YvtpukxvGWe3rwVxUJQWsiRLGazWxf/JCEQOcsd2GXT98W2OGjWVFQP4ByKH3rjKw nf/pSOtkIHh686VgmhBJ1iWyu31MU4XQBOtPxiJlRFO6aMjyamG/DiCHXJnQlZGpn7glWIx47W Xxg= X-SBRS: 2.7 X-MesageID: 14716097 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,286,1580792400"; d="scan'208";a="14716097" From: Andrew Cooper To: Xen-devel Date: Fri, 20 Mar 2020 21:24:49 +0000 Message-ID: <20200320212453.21685-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200320212453.21685-1-andrew.cooper3@citrix.com> References: <20200320212453.21685-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/4] x86/ucode/amd: Fix assertion in compare_patch() 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is clearly a typo. Fixes: 9da23943ccd "microcode: introduce a global cache of ucode patch" Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index 99e2449eee..d4b2874de6 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -222,7 +222,7 @@ static enum microcode_match_result compare_patch( =20 /* Both patches to compare are supposed to be applicable to local CPU.= */ ASSERT(microcode_fits(new->mc_amd) !=3D MIS_UCODE); - ASSERT(microcode_fits(new->mc_amd) !=3D MIS_UCODE); + ASSERT(microcode_fits(old->mc_amd) !=3D MIS_UCODE); =20 return compare_header(new_header, old_header); } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 14:55:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1584739551; cv=none; d=zohomail.com; s=zohoarc; b=UQ3kdum2T2DY+QHR3pseA/h0RLsVTDWsUu2TPOP2irk4u4gB2OexvNWa8DnsrajlEGnbxaRdasoisYuQPHpHJlGmgDNhJCQrfYkwckuB0n5vM5R8DErDLJNBHQnlyjQ+/1HNFXrfoE72Zu83df3fITzlI2dtliPuKJK/BE4ppQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584739551; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=afk/0hSaa7xBPMY40qRLDz53BnkYr0ZPO/bu3HY6GuI=; b=XDPflB832OQj5VY+oAE1YyHMzSc6mA5nX65Q0EpuV3ffA2e4OqxydckVhSGZDNq5XrKK7zbpb1kDN+UJB+XkUq4762zB2d9ar+TnmmjXK2y/GjnU8g4FHGW/Y0SWhBrXU+NpzrSQ6VOZ+DNdfE4XRQpd7ldc+xsVBMiPz7Vfzi0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584739551410427.83587584491056; Fri, 20 Mar 2020 14:25:51 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8h-0003uH-1N; Fri, 20 Mar 2020 21:25:11 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8g-0003u3-8X for xen-devel@lists.xenproject.org; Fri, 20 Mar 2020 21:25:10 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 40a20f60-6af1-11ea-be18-12813bfff9fa; Fri, 20 Mar 2020 21:25:00 +0000 (UTC) X-Inumbo-ID: 40a20f60-6af1-11ea-be18-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584739500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RBQi4FtTtH8S07eLiEJoFsDh4jC3Cj57iZU7zh4E8vI=; b=WATd6HA3oxmlSZasq+bedkIMVhrQE3sBeMvzxDfy738S4mZoD1gZ+KUR kzLdsq5U4DhZytGcSCgE0EG7RtYjh3RtyyBJ+LGXUcVBfbGDLc62KGdFL IYiUrBbeN2D1sHZwx9lm3Rcdz+Pdr79YT6bbWNor6EHfxL29IBeRG9ASc w=; Authentication-Results: esa5.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: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 3TRS0Zvbb6fY/iambXIdHVxTEMdcb+NYBHI4vF4oQYessG6RNQU00guQJv8x/Le9EQh2bMTOfI AZON4BbKT/CyD4QiVVFY4d3j0UtszU0W/KPz6W3Aal3ZtgxXCEgofoa1f5k3LKS3GK4VSwJ/ZB Z/mEO1MEsjPWfU2PNcBhlAHoR6kgxvSJCXAeIeyLZ/lA0SrpiDY4ATu0BziIIl1V+ANqzeQ84E EqtYbrOnmDWzJeyou5yikJTNPzVsCVg5HgpaboBQMCTU9xIN1TBe5qIippuvK+FQb7LU9WyMJy ghY= X-SBRS: 2.7 X-MesageID: 14716098 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,286,1580792400"; d="scan'208";a="14716098" From: Andrew Cooper To: Xen-devel Date: Fri, 20 Mar 2020 21:24:50 +0000 Message-ID: <20200320212453.21685-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200320212453.21685-1-andrew.cooper3@citrix.com> References: <20200320212453.21685-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] x86/ucode: Fix error paths in apply_microcode() 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 , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In the unlikley case that patch application completes, but the resutling revision isn't expected, sig->rev doesn't get updated to match reality. It will get adjusted the next time collect_cpu_info() gets called, but in t= he meantime Xen might operate on a state value. Nothing good will come of thi= s. Rewrite the logic to always update the stashed revision, before worring abo= ut whether the attempt was a success or failure. Take the opportunity to make the printk() messages as consistent as possibl= e. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu --- -CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 14 +++++++------- xen/arch/x86/cpu/microcode/intel.c | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index d4b2874de6..a053e43923 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -229,11 +229,11 @@ static enum microcode_match_result compare_patch( =20 static int apply_microcode(const struct microcode_patch *patch) { - uint32_t rev; int hw_err; unsigned int cpu =3D smp_processor_id(); struct cpu_signature *sig =3D &per_cpu(cpu_sig, cpu); const struct microcode_header_amd *hdr; + uint32_t rev, old_rev =3D sig->rev; =20 if ( !patch ) return -ENOENT; @@ -249,6 +249,7 @@ static int apply_microcode(const struct microcode_patch= *patch) =20 /* get patch id after patching */ rdmsrl(MSR_AMD_PATCHLEVEL, rev); + sig->rev =3D rev; =20 /* * Some processors leave the ucode blob mapping as UC after the update. @@ -259,15 +260,14 @@ static int apply_microcode(const struct microcode_pat= ch *patch) /* check current patch id and patch's id for match */ if ( hw_err || (rev !=3D hdr->patch_id) ) { - printk(KERN_ERR "microcode: CPU%d update from revision " - "%#x to %#x failed\n", cpu, rev, hdr->patch_id); + printk(XENLOG_ERR + "microcode: CPU%u update rev %#x to %#x failed, result %#x\= n", + cpu, old_rev, hdr->patch_id, rev); return -EIO; } =20 - printk(KERN_WARNING "microcode: CPU%d updated from revision %#x to %#x= \n", - cpu, sig->rev, hdr->patch_id); - - sig->rev =3D rev; + printk(XENLOG_WARNING "microcode: CPU%u updated from revision %#x to %= #x\n", + cpu, old_rev, hdr->patch_id); =20 return 0; } diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 5e9c2a9c7f..6ac5f98694 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -278,10 +278,10 @@ static enum microcode_match_result compare_patch( static int apply_microcode(const struct microcode_patch *patch) { uint64_t msr_content; - unsigned int val[2]; - unsigned int cpu_num =3D raw_smp_processor_id(); + unsigned int cpu =3D smp_processor_id(); struct cpu_signature *sig =3D &this_cpu(cpu_sig); const struct microcode_intel *mc_intel; + uint32_t rev, old_rev =3D sig->rev; =20 if ( !patch ) return -ENOENT; @@ -302,20 +302,20 @@ static int apply_microcode(const struct microcode_pat= ch *patch) =20 /* get the current revision from MSR 0x8B */ rdmsrl(MSR_IA32_UCODE_REV, msr_content); - val[1] =3D (uint32_t)(msr_content >> 32); + sig->rev =3D rev =3D msr_content >> 32; =20 - if ( val[1] !=3D mc_intel->hdr.rev ) + if ( rev !=3D mc_intel->hdr.rev ) { - printk(KERN_ERR "microcode: CPU%d update from revision " - "%#x to %#x failed. Resulting revision is %#x.\n", cpu_num, - sig->rev, mc_intel->hdr.rev, val[1]); + printk(XENLOG_ERR + "microcode: CPU%u update rev %#x to %#x failed, result %#x\= n", + cpu, old_rev, mc_intel->hdr.rev, rev); return -EIO; } - printk(KERN_INFO "microcode: CPU%d updated from revision " - "%#x to %#x, date =3D %04x-%02x-%02x\n", - cpu_num, sig->rev, val[1], mc_intel->hdr.year, + + printk(XENLOG_WARNING + "microcode: CPU%u updated from revision %#x to %#x, date =3D %0= 4x-%02x-%02x\n", + cpu, old_rev, rev, mc_intel->hdr.year, mc_intel->hdr.month, mc_intel->hdr.day); - sig->rev =3D val[1]; =20 return 0; } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 14:55:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1584739555; cv=none; d=zohomail.com; s=zohoarc; b=aTsyLSeo1bQwrAG3QOLAeAKNrfkVmLUled7l6XZE2EnzBKq2vVKrXWnnoclP4RKNA541IhP+MsCi1deeyCzauH3+IhgIiErsl/uAps+2uFkxUb0QVJu+KuvenBZ0k2DJZd6pG5Qux6I50AYEVOQUIAU6vzChya1ad1HgdiJZldA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584739555; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IsvkEsnDeUXjmIq+s8HIJEHK875668gpihpr8byP5sc=; b=knYXMm8mejfGvk0dmjbbsKEqQOTZHW0kaLS+6eKVPXcclHhFCHFC4MqVs75pR2B/jwI34o8ZqAuP76vc/qmAcBKtObLB/TwiKZzZLQ8r6/i6BdAyckIq0uCNuc1xW3EpyFPiW4PZ4fhVG7sMyrSHOb1XeRkj2XOKOyqN6vrRHLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584739555244358.07276684627925; Fri, 20 Mar 2020 14:25:55 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8m-0003w5-B3; Fri, 20 Mar 2020 21:25:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8l-0003v9-8X for xen-devel@lists.xenproject.org; Fri, 20 Mar 2020 21:25:15 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 425a449b-6af1-11ea-be19-12813bfff9fa; Fri, 20 Mar 2020 21:25:02 +0000 (UTC) X-Inumbo-ID: 425a449b-6af1-11ea-be19-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584739502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yp/861rLdxwmVg8ZyVF+rmArBo6QMsLefGFaDVLdQSs=; b=IsJ86K4j3TmWhgWkUlCjKR8XAkKN6UO39jETlNGcL2aGPRqfalj6NkA6 280qz5eDajE2zzjWMcCg2q7LZMaaabVvqMwi+uytYjXmAx3Km15TLJuMb +6K+Rvi/dGrIOFyTzdZpgV1QIWMX4ZaRwAaei30nD4920fSRoUNGfCxwU I=; Authentication-Results: esa5.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: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: /VJBbAEGva673Cp9VTThZmy4teoqf/DYPrD+56kE2+xteGpLwnkTX5Qq9w/B0LWymf6KW4zhrV UKzxdQWJUK5rMZraHSKArwYubalmx1wrSZFP1aD+7Xt1ZE867Uas2w00k7Rec7MVMfKy1gIrS9 tVBW/eG1iMtTflvBSrZVH0vlI5FMqinZGXXxrQN+Unjpbfo+G2PhqVlm/XULHm6zzXmZLg1KdN sB87NVE9asbQZNg07ndwSnrQWJyiC1tBjk7HvrSiybVgPPqf/hgmtsiqF0XH14VSXsxIlsyhYC dOg= X-SBRS: 2.7 X-MesageID: 14716099 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,286,1580792400"; d="scan'208";a="14716099" From: Andrew Cooper To: Xen-devel Date: Fri, 20 Mar 2020 21:24:51 +0000 Message-ID: <20200320212453.21685-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200320212453.21685-1-andrew.cooper3@citrix.com> References: <20200320212453.21685-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] xen: Drop raw_smp_processor_id() 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: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Jan Beulich , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) There is only a single user of raw_smp_processor_id() left in the tree (and= it is unconditionally compiled out). Drop the alias from all architectures. Signed-off-by: Andrew Cooper Acked-by: Julien Grall Reviewed-by: Wei Liu --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk --- xen/arch/x86/cpu/microcode/amd.c | 2 +- xen/include/asm-arm/smp.h | 2 +- xen/include/asm-x86/smp.h | 2 +- xen/include/xen/smp.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index a053e43923..0998a36b5c 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -306,7 +306,7 @@ static int get_ucode_from_buffer_amd( memcpy(mc_amd->mpb, mpbuf->data, mpbuf->len); =20 pr_debug("microcode: CPU%d size %zu, block size %u offset %zu equivID = %#x rev %#x\n", - raw_smp_processor_id(), bufsize, mpbuf->len, *offset, + smp_processor_id(), bufsize, mpbuf->len, *offset, ((struct microcode_header_amd *)mc_amd->mpb)->processor_rev_i= d, ((struct microcode_header_amd *)mc_amd->mpb)->patch_id); =20 diff --git a/xen/include/asm-arm/smp.h b/xen/include/asm-arm/smp.h index fdbcefa241..af5a2fe652 100644 --- a/xen/include/asm-arm/smp.h +++ b/xen/include/asm-arm/smp.h @@ -12,7 +12,7 @@ DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask); =20 #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) =20 -#define raw_smp_processor_id() (get_processor_id()) +#define smp_processor_id() get_processor_id() =20 /* * Do we, for platform reasons, need to actually keep CPUs online when we diff --git a/xen/include/asm-x86/smp.h b/xen/include/asm-x86/smp.h index 6150363655..f7485f602e 100644 --- a/xen/include/asm-x86/smp.h +++ b/xen/include/asm-x86/smp.h @@ -53,7 +53,7 @@ int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t = pxm); * from the initial startup. We map APIC_BASE very early in page_setup(), * so this is correct in the x86 case. */ -#define raw_smp_processor_id() (get_processor_id()) +#define smp_processor_id() get_processor_id() =20 void __stop_this_cpu(void); =20 diff --git a/xen/include/xen/smp.h b/xen/include/xen/smp.h index a64c9b3882..d5a3644611 100644 --- a/xen/include/xen/smp.h +++ b/xen/include/xen/smp.h @@ -65,8 +65,6 @@ void smp_call_function_interrupt(void); =20 void smp_send_call_function_mask(const cpumask_t *mask); =20 -#define smp_processor_id() raw_smp_processor_id() - int alloc_cpu_id(void); =20 extern void *stack_base[NR_CPUS]; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 26 14:55:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1584739551; cv=none; d=zohomail.com; s=zohoarc; b=Px3WXUZ8gj7XhQeBPlrHJr6z1eyjl7BCex7EKYTlUgKBZFDAQdtinX2itO1WRc6aOEaSEAbULhlKAdqCK75x3AQ5SfPxr8P0IME5lI6XbaY0TtVbi0q4VNwyI6ic4ykkCw99A9EAzr26koH45EqALnkLrRn4/wIWATvwMBpEIX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584739551; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Wl2AYXHZfMqjGcHgoHpcbr05uDfB326bH1/w5P21aM=; b=VxiEcM/j2LZF8KJKGGXFqTwpkUKa4QIGul5mbFTfJpwoIT2GU/RuOuoOUWwxjyXrAdYVmwQ7vwzun/n9AEoWHCbQ452tEkmff8XWtjw5u85Ar9NHJOjN2a6jLM5i26EKxhtb/BmUiO/0+Gq4TCHBCc45dk95xLikHUbR/GfDZVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584739551862629.1378739814027; Fri, 20 Mar 2020 14:25:51 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8c-0003tJ-HC; Fri, 20 Mar 2020 21:25:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jFP8b-0003t6-2f for xen-devel@lists.xenproject.org; Fri, 20 Mar 2020 21:25:05 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 434b48b8-6af1-11ea-a6c1-bc764e2007e4; Fri, 20 Mar 2020 21:25:04 +0000 (UTC) X-Inumbo-ID: 434b48b8-6af1-11ea-a6c1-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1584739504; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s0Zn8myHzjApfW+BC4Q0BA7rfRL+0OX3tz6cOs5uv+8=; b=fPlCFntXIqtYAZ/iIoew6FT38+PJceG/MiYzvkDz86cwZ/4yXZoPeOVD 9VVc92SzLFYhrNjdWxzBdBZ9WYXoQO+pBqtsN4GfJ8sFZMG9JBIk/n7jN wExoqDGb85eyVcyYdN8ez2hdAhVvKFhffUDtoWLYyxwFJsyYY20dLsWLY g=; Authentication-Results: esa6.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: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: JRHYcfyRl5KSUmPI3Ohe9Nq4kMcJOVMvaXu89Mq1qCEr/S+FFeoMI/DgBjxkOsSh+9jR+PVWAy oQ97mB4qZMzUL0EmNQRcDu3f86J94/T6RK8T4t18UXougtk3pv/8dzF7Y9EIf11PY0CZBujTqT rjpWYTWt41826lNJqe5TPFGuj3CyLP1PEAdpECTwwWV60TkjPLdg1CJHs7tTuWMbXSU6Mkw+HP qNJn10qMf/aAtFcy5r2DlFMBycKafvNkTw55hYwjfA2GV+En+W5mNAO+IR9cA9x0DccZxDxVSc ryk= X-SBRS: 2.7 X-MesageID: 14795899 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,286,1580792400"; d="scan'208";a="14795899" From: Andrew Cooper To: Xen-devel Date: Fri, 20 Mar 2020 21:24:52 +0000 Message-ID: <20200320212453.21685-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200320212453.21685-1-andrew.cooper3@citrix.com> References: <20200320212453.21685-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/4] xen: Introduce a xmemdup_bytes() helper 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Use it to simplify the x86 microcode logic, taking the opportunity to drop = the -ENOMEM printks. Signed-off-by: Andrew Cooper Acked-by: Julien Grall Reviewed-by: Wei Liu --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpu/microcode/amd.c | 9 ++------- xen/arch/x86/cpu/microcode/intel.c | 7 ++----- xen/include/xen/xmalloc.h | 11 +++++++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/= amd.c index 0998a36b5c..12a3b6b32c 100644 --- a/xen/arch/x86/cpu/microcode/amd.c +++ b/xen/arch/x86/cpu/microcode/amd.c @@ -299,11 +299,10 @@ static int get_ucode_from_buffer_amd( return -EINVAL; } =20 - mc_amd->mpb =3D xmalloc_bytes(mpbuf->len); + mc_amd->mpb =3D xmemdup_bytes(mpbuf->data, mpbuf->len); if ( !mc_amd->mpb ) return -ENOMEM; mc_amd->mpb_size =3D mpbuf->len; - memcpy(mc_amd->mpb, mpbuf->data, mpbuf->len); =20 pr_debug("microcode: CPU%d size %zu, block size %u offset %zu equivID = %#x rev %#x\n", smp_processor_id(), bufsize, mpbuf->len, *offset, @@ -336,14 +335,10 @@ static int install_equiv_cpu_table( return -EINVAL; } =20 - mc_amd->equiv_cpu_table =3D xmalloc_bytes(mpbuf->len); + mc_amd->equiv_cpu_table =3D xmemdup_bytes(mpbuf->data, mpbuf->len); if ( !mc_amd->equiv_cpu_table ) - { - printk(KERN_ERR "microcode: Cannot allocate memory for equivalent = cpu table\n"); return -ENOMEM; - } =20 - memcpy(mc_amd->equiv_cpu_table, mpbuf->data, mpbuf->len); mc_amd->equiv_cpu_table_size =3D mpbuf->len; =20 return 0; diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcod= e/intel.c index 6ac5f98694..f26511da98 100644 --- a/xen/arch/x86/cpu/microcode/intel.c +++ b/xen/arch/x86/cpu/microcode/intel.c @@ -339,13 +339,10 @@ static long get_next_ucode_from_buffer(struct microco= de_intel **mc, return -EINVAL; } =20 - *mc =3D xmalloc_bytes(total_size); + *mc =3D xmemdup_bytes(mc_header, total_size); if ( *mc =3D=3D NULL ) - { - printk(KERN_ERR "microcode: error! Can not allocate memory\n"); return -ENOMEM; - } - memcpy(*mc, (const void *)(buf + offset), total_size); + return offset + total_size; } =20 diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h index f515ceee2a..16979a117c 100644 --- a/xen/include/xen/xmalloc.h +++ b/xen/include/xen/xmalloc.h @@ -51,6 +51,17 @@ #define xmalloc_bytes(_bytes) _xmalloc(_bytes, SMP_CACHE_BYTES) #define xzalloc_bytes(_bytes) _xzalloc(_bytes, SMP_CACHE_BYTES) =20 +/* Allocate untyped storage and copying an existing instance. */ +#define xmemdup_bytes(_src, _nr) \ + ({ \ + unsigned long nr_ =3D (_nr); \ + void *dst_ =3D xmalloc_bytes(nr_); \ + \ + if ( dst_ ) \ + memcpy(dst_, _src, nr_); \ + dst_; \ + }) + /* Free any of the above. */ extern void xfree(void *); =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel