From patchwork Fri Feb 2 03:51:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Tk9NVVJBIEpVTklDSEko6YeO5p2RIOa3s+S4gCk=?= X-Patchwork-Id: 195553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp191457dyc; Thu, 1 Feb 2024 19:52:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3nhkFBfbe6Y/WGDc8llPwAVFA00gbjE0kv7OPLdhoWIMTXWd9LFI6lGV8A7bT9j8IDmQr X-Received: by 2002:a17:906:f6d3:b0:a35:7438:1141 with SMTP id jo19-20020a170906f6d300b00a3574381141mr5200281ejb.45.1706845924258; Thu, 01 Feb 2024 19:52:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW5TqlOGfXIlCgIGdQReWx1qhCe6qWbIQXE8Yw8eWXHEE8gmMQ5OyEckia/UUz+kkfg0Qg5Srpg593nASi7AJ3SkS8r3A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m18-20020a17090607d200b00a34976db3e9si425518ejc.1047.2024.02.01.19.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 19:52:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49158-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@nec.com header.s=selector2 header.b=NdBqHVK7; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-49158-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49158-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=nec.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DB8BB1F240EA for ; Fri, 2 Feb 2024 03:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 727B6F4EA; Fri, 2 Feb 2024 03:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nec.com header.i=@nec.com header.b="NdBqHVK7" Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2046.outbound.protection.outlook.com [40.107.113.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FC68DF5E for ; Fri, 2 Feb 2024 03:51:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.113.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706845908; cv=fail; b=D6/vE8IW9HmzBS6uIEuj1YQLdE6/jLhjEg3Y6Pug0BwqbYSqC7KceicZU0HdbrCmA2XQz6kT2JWC5PMBdu6goTFyLKGyP29awXcb2Nc94FQBGtHSZC+xGxFFS0RtByygiZKnrg2wnoy6QPVPWvrTriVuJ8hTcH45Ep+swFTrBJw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706845908; c=relaxed/simple; bh=rNZcMsa9yRvdOqjIjKL/KeyxlwFu/PIj3bzlY0fYAi0=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=tKvG4XOxdRx1TsD6kFcY69ph7fSQ7P3HsxCV4N0MIeLNECamIKBLJeYXgaIURLckGAU631+K9LY94w/NEYkltO8+9fyRbRyJAtimSvDkMbj8IlLtKy7mTF+Qz29UIXEJH29dF/uhYJWho/rWy124U4oABaE3iPo50w6HXx33VCw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nec.com; spf=pass smtp.mailfrom=nec.com; dkim=pass (2048-bit key) header.d=nec.com header.i=@nec.com header.b=NdBqHVK7; arc=fail smtp.client-ip=40.107.113.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nec.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HozRGI3KIhx6p3tC4fq8HNGqKQII7fHuFZ7B3opjci5RLsT++QlqoBc6H6BCxIhvXpr4LQwgljQGp9GsASf0bnfHT/JXRilI/YpXsMHBAbNvqQQquB0WHHQUS5sgOAkFc5cd6nksEMiLgXWSS7qFkXEM0rbJxy3lYRPzWQ5C8orMef5zN+Otu0ozF6G6H/Ti8R+ip9wj96or4cUqq4yxAjjPTB7tC+07tebGWFJKM77dT6OU3UjtcD+zGH0kDlAntva6sG/1BtghfMIPgP8ZBiD2MLzLIWiSX99nhnnqUdpQhIBNYXo2qL0JiL/SfjCHlVO+f34Mp/asxuSU+MgHWA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8LCNOaXIkA/4uTRpN0/FbM3LP4tZxsvhPRsUPLCGi10=; b=VpDPyr+2lVEVY7hRY6b0864ygScin9ECExvbCOHD8S8XhvplCx+hlzzTM+a1m9VJao2AqxIV0q1YrSarOoqNhaumBPZ5i5tOUeQSAqfoP6abEsFlEvdumTg7CZ81ovBTpuNK5he5Mz40bXrKBbMV5GLe4mNGJoRQD5Z6eNgkdjctfOf6crbq8GGuekeE75cQoH2LDGdZ90OA2YbO8XisWm5Yv9eyURzuhmh12Kvjd4Z8SmGqTOgOieACedtMxZzpkdFjv32hFaWhkSf/BoXPqStiXiSIMdRsqg/EC2aBI4bYokNTMdW8X3UesFse77QA52bEPBR+qwIIRoMAzWvTQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nec.com; dmarc=pass action=none header.from=nec.com; dkim=pass header.d=nec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nec.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8LCNOaXIkA/4uTRpN0/FbM3LP4tZxsvhPRsUPLCGi10=; b=NdBqHVK7lKORCDOPf9K88BBxAmca61TsmSn9ZwEMoqi/fMidZNavB+cScj5tinVKF9M+Zgo3HlmjxVHDUdYy7/Exv6E687i1pfRtlZUaB1yCqGW/ag2Kce+MTvnIsVIHoiG4xaKrjujM6KZssB2TQFtDPjb18K4I1oBvNGup/oPssFCbcFzv4uxWPFIfzx76xvKSgwfWl8a+9c1cWGRJvplHQKoxmt/RZLpJB7xqv0AU9FFtD3G+d6XKFmEEyX5ZTaTks3q/u6xOgdSXEqv4eTSh9WYV2eKu/xHN4EcDutZ0fiym1xvfmnWlIhfnyaaRhA/HWCkRUurIKKOUJCa3Ig== Received: from TYCPR01MB8389.jpnprd01.prod.outlook.com (2603:1096:400:15f::5) by OS7PR01MB11820.jpnprd01.prod.outlook.com (2603:1096:604:23a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.24; Fri, 2 Feb 2024 03:51:43 +0000 Received: from TYCPR01MB8389.jpnprd01.prod.outlook.com ([fe80::1d90:2d0b:4619:5a7d]) by TYCPR01MB8389.jpnprd01.prod.outlook.com ([fe80::1d90:2d0b:4619:5a7d%5]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 03:51:43 +0000 From: =?iso-2022-jp?b?Tk9NVVJBIEpVTklDSEkoGyRCTG5CPCEhPV8wbBsoQik=?= To: "x86@kernel.org" , "mingo@redhat.com" , "tglx@linutronix.de" , "bp@alien8.de" , "dave.hansen@linux.intel.com" CC: "hpa@zytor.com" , "ardb@kernel.org" , "david@redhat.com" , "debarbos@redhat.com" , "dzickus@redhat.com" , "jlelli@redhat.com" , =?iso-2022-jp?b?Tk9NVVJBIEpVTklD?= =?iso-2022-jp?b?SEkoGyRCTG5CPCEhPV8wbBsoQik=?= , "kirill.shutemov@linux.intel.com" , "lgoncalv@redhat.com" , "linux-kernel@vger.kernel.org" , "nikunj@amd.com" , "thomas.lendacky@amd.com" Subject: [PATCH 1/2] x86/boot: Add error_putdec() helper Thread-Topic: [PATCH 1/2] x86/boot: Add error_putdec() helper Thread-Index: AQHaVYsi/1oB6HDI3k25PP/X1Nkmaw== Date: Fri, 2 Feb 2024 03:51:43 +0000 Message-ID: <20240202035052.17963-1-junichi.nomura@nec.com> Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.43.0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nec.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYCPR01MB8389:EE_|OS7PR01MB11820:EE_ x-ms-office365-filtering-correlation-id: 68e7c3c3-ba9b-479e-3459-08dc23a24561 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dRhIv+Ae21gWJtePCtXfWs9DfzbCy32M5hYnAO84hMfBgrNF3g4jycWPWSSb9Fk4a2Z8P3kbnjM7coYkB3UAvzWf1CJEMRVX9w+PzewzDJcSYX7DDfRkBZHyB91UxozhTRrAf8sEQl66rs1PadC1KqLN3gmbpRsZLIRza7OEay6Hhm9Zo1Wk5NaTVD+mHmZT07I3U4AACl/QVZsZ6ngj0tb1b4O8EWjuC9dtyn805gtJz7z3zejcH66YWJRRTdsc22CsZLn1EKwITUCEM9wRCUJ2U9DXgqUVG0R3P3CUpaVBmUuraOxc+PCHTCid3ntm/xSLcOiSp6Q/0cmtruQ0fdDD+lsEUGPzk9bv90boMGkD/V48Uyde8UcF9aBOTxKskZ9IjOip4uYcOSLm/FOzPRQa2ybq5n/ViCRNXo8Mzhyw7waRBfnay30TxrpFu7uuYI3/ZRuatKhStVsxEToWDUkBbAQ3uzvJ9emWlPFGaSOyceytlEhSeYGq4IFZ+XC1FhrcJw+YZvtrrKgTdnZvXV/UruNgw76uAjZIX2M8QlWFV4LGPezGQi72iBoj9AKfafCsip3IDLx4NpXGPRO2oDd3vcfL5Vlmq2r/m+AfvIs= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB8389.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(366004)(39860400002)(396003)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(38070700009)(4326008)(66476007)(5660300002)(66946007)(316002)(966005)(478600001)(6486002)(76116006)(66446008)(7416002)(110136005)(54906003)(2616005)(8676002)(6506007)(64756008)(71200400001)(8936002)(66556008)(26005)(2906002)(6512007)(1076003)(122000001)(36756003)(38100700002)(41300700001)(82960400001)(85182001)(86362001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-2022-jp?b?NCtxOHZhUEJwMGI5YUNt?= =?iso-2022-jp?b?LzQ4MHZ0Y3hOM2RtMVVQRjRzQU0vVWVUd2NKaitudHNZcEFoN3h3M2JK?= =?iso-2022-jp?b?S1BtMG5qTVl5Z1duVVVnTHc0UEcvWTdBd2lwaHVKSW1uVS9IUkhyNy80?= =?iso-2022-jp?b?SS9iMUtCRi9xTkd2U3U0eG9PbmNxZTVMKzZMZEhYNnllRzZGbD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lmbjhDbUNYZnRUSTIvNGo3TVJDRHcwYUtic09XeDRQ?= =?iso-2022-jp?b?bWFiUURlOVFLRXozRXRnSmNkL1hWanBtMkE2bUJ1QnU1c3EzcVI2KzA0?= =?iso-2022-jp?b?TXdQTFJiTlVxaGxXUFVyMEtqeTQvVkh1amtPcU95bWt5S2NtYWVvaUJC?= =?iso-2022-jp?b?bDVpV0JhMWIwUUREQUlaNm1pamt4ZXc0RkFrV3VpdUNBallOdWlIS01P?= =?iso-2022-jp?b?bUxhelFOYUZFVHhvdTlDODJUQm9FSWlKdnRWWm96M0VjbEZMMzhldmsy?= =?iso-2022-jp?b?cFhndnBuK1M0N2dTbGtBZmMvc1JQQmkxSUUzT2RuRTdCYkduY2NWb1dv?= =?iso-2022-jp?b?NWVWNlVLYkZhd3c9PQ==?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: nec.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB8389.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68e7c3c3-ba9b-479e-3459-08dc23a24561 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2024 03:51:43.5114 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: e67df547-9d0d-4f4d-9161-51c6ed1f7d11 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OUU6wAc7HyJcYUuQVP0va92EZ0xIZX+67rabb8yIWCSS5H0GObFbW2+HoO+q+AYoYgk4pDJwyBr9T2fhc+3+cg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS7PR01MB11820 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789757671740302078 X-GMAIL-MSGID: 1789757671740302078 From: "H. Peter Anvin" Add a helper to print decimal numbers to early console. Suggested-by: Borislav Petkov (AMD) Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Jun'ichi Nomura Link: https://lore.kernel.org/lkml/20240123112624.GBZa-iYP1l9SSYtr-V@fat_crate.local/ diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -164,21 +164,34 @@ void __putstr(const char *s) outb(0xff & (pos >> 1), vidport+1); } -void __puthex(unsigned long value) +static noinline void __putnum(unsigned long value, unsigned int base, + int mindig) { - char alpha[2] = "0"; - int bits; + char buf[8*sizeof(value)+1]; + char *p; - for (bits = sizeof(value) * 8 - 4; bits >= 0; bits -= 4) { - unsigned long digit = (value >> bits) & 0xf; + p = buf + sizeof(buf); + *--p = '\0'; - if (digit < 0xA) - alpha[0] = '0' + digit; - else - alpha[0] = 'a' + (digit - 0xA); + while (mindig-- > 0 || value) { + unsigned char digit = value % base; + digit += (digit >= 10) ? ('a'-10) : '0'; + *--p = digit; - __putstr(alpha); + value /= base; } + + __putstr(p); +} + +void __puthex(unsigned long value) +{ + __putnum(value, 16, sizeof(value)*2); +} + +void __putdec(unsigned long value) +{ + __putnum(value, 10, 1); } #ifdef CONFIG_X86_NEED_RELOCS diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -63,8 +63,10 @@ void *malloc(int size); void free(void *where); void __putstr(const char *s); void __puthex(unsigned long value); +void __putdec(unsigned long value); #define error_putstr(__x) __putstr(__x) #define error_puthex(__x) __puthex(__x) +#define error_putdec(__x) __putdec(__x) #ifdef CONFIG_X86_VERBOSE_BOOTUP From patchwork Fri Feb 2 03:51:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Tk9NVVJBIEpVTklDSEko6YeO5p2RIOa3s+S4gCk=?= X-Patchwork-Id: 195554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp191807dyc; Thu, 1 Feb 2024 19:53:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuUkNywjaG2B9iYhLvpcmIUsgn26PQPHd1YSzeloheUNtttJCboEOLTABRt/RLaYYTW043 X-Received: by 2002:a17:903:2291:b0:1d8:f6af:77db with SMTP id b17-20020a170903229100b001d8f6af77dbmr1750028plh.12.1706846006304; Thu, 01 Feb 2024 19:53:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV+uOO8vWnOoQpP8YrB35Ve62AahvUJdICUGk+7SRZV4pW1ZUmAMH8ObtrVpzR1usMmZF+yLn2zuSx3DzuooIv4qjg0jA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k36-20020a63ff24000000b005d8bc09efbdsi872100pgi.881.2024.02.01.19.53.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 19:53:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49159-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@nec.com header.s=selector2 header.b="m/4VTl8S"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-49159-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49159-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=nec.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 902FF2835AD for ; Fri, 2 Feb 2024 03:52:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 690A4F4F8; Fri, 2 Feb 2024 03:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nec.com header.i=@nec.com header.b="m/4VTl8S" Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2042.outbound.protection.outlook.com [40.107.113.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 317CCF4FA for ; Fri, 2 Feb 2024 03:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.113.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706845925; cv=fail; b=dLhzeZ1L42kekqObbDsqQeo3fKeGRDpPwI7WHwd+yGx8qFyIXZaCK1V2z88m/wLdCh7pOCtYcsgAE1lpCeburECWIoe4ExXRN4n0HRRZ65mKlbBN06RL+RyvOcyEOLq6kbbssQyl03dD6mk0UkYdslFqZFX/GbL/vrqNlfsowG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706845925; c=relaxed/simple; bh=mh8hlDsU7a5vSSmuUuUMn0lnX6RYT/N3ldMf5+vyTBk=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=Dx/mQPxMRS+CRTCHgCjlT7C0C+pUQ/MsTnNq+EciNrZSu2hgKUuqzY9+jCjk7mx7tyMtilTRsZQ9VNjEOSISIrq/rmz3lsPUJ1YjPP7H2CKkHfTXDbqxJwPfYetrc+4O/eEsMP1hWqzjUAeSF5d3WUxTLk3KodtXNyp7a3VxSIE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nec.com; spf=pass smtp.mailfrom=nec.com; dkim=pass (2048-bit key) header.d=nec.com header.i=@nec.com header.b=m/4VTl8S; arc=fail smtp.client-ip=40.107.113.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nec.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wep8RHRdXmfH4wddrjp4HgCqHroodrdnlve9axiQK1oZCHhUSLWa4URBxcZuYwn5NkxId+FTZJF/QBLjoo+eEITrVIQe+3MdYQN5VFEMcy4JEVHNCSdrNixQQrH/SE9eAuCkgM13iSzpMvfgGYte7L5zC5X4iwgyEBFE0OUebNF3tR7WT8tIc7cuxZOYt5maq0DYHD2v/ZDmDJO5+Ca8gjK2BcPnwNrtnFstwKY/75xblJkjf1tpR5aY6/ooL7fqOb6uCbj0gOVa9UoTURZd2MhuRkXwCSRDrFPdleKMT1EI3gUmcSXnHcPyWSLcRBsPRtmeRcUPRoFsWhR46AUF8w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L75p96dcJK8isJ9dYgE6R/ovATfdO96AeaCGaSb4f04=; b=NGUvfLcwvk7R9qxtDLs6n5wYe8rNe65kCD6lOwrfSCRCeJJsBRhlxcZCDtP3ev1q5ZHP+6uzbuB5M8aMStFQLkjAfk7m0Cq2Xd14z8Ni6kzkwbQfLN/30ijAEHGdgMjJspP5XSJEYyTaf8y7+2vhsT6bGOhT4fwjfRMvbsiiX/UPIUWrWHMbF+Ks1H6cBruaQgrtDVoWo86srma6f869o7epy2lXPVdTgmTXjD+qz+0uGIYV/wv2DAzTr5k+DJqa69kBwoIE1IHIoG4l1yzU58+RKCBjTimLgI0jPY/l8YtCdGO+j7z4q70zcObfk1mlkW3SnYt3x4kl8fatRy2c/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nec.com; dmarc=pass action=none header.from=nec.com; dkim=pass header.d=nec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nec.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L75p96dcJK8isJ9dYgE6R/ovATfdO96AeaCGaSb4f04=; b=m/4VTl8SLxMaPA2GIoc/xAKDbDRmZ9bvIx7lUP6NQ6XKOuqo8AuOKYYgWFlsQn09DdlUARdw0mue3FTHYFtl54NswTBJ18WbCq9Ace0Mz2Zkuq89aRLNkSl/MENqYVtbzTg4qiS8zE8YPDcWW31qFhbrHqjjZC9WXblWfp+k9gwSDFXnywZ8mfCAQ58aSTFa4MH9D8AIUjodqp82g4c9b/1pW560NEwyv0dvL93iX3s83I0d4E51MvQKghgUUG/QUczgV184B59hdseMl07S9Cqj+S3TKdE5ePhHoC8BVoEgNNSjbm0fbQoqlCDodITfP8qpMe62V9FvFnWPmW1EuQ== Received: from TYCPR01MB8389.jpnprd01.prod.outlook.com (2603:1096:400:15f::5) by OS7PR01MB11820.jpnprd01.prod.outlook.com (2603:1096:604:23a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.24; Fri, 2 Feb 2024 03:51:59 +0000 Received: from TYCPR01MB8389.jpnprd01.prod.outlook.com ([fe80::1d90:2d0b:4619:5a7d]) by TYCPR01MB8389.jpnprd01.prod.outlook.com ([fe80::1d90:2d0b:4619:5a7d%5]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 03:51:58 +0000 From: =?iso-2022-jp?b?Tk9NVVJBIEpVTklDSEkoGyRCTG5CPCEhPV8wbBsoQik=?= To: "x86@kernel.org" , "mingo@redhat.com" , "tglx@linutronix.de" , "bp@alien8.de" , "dave.hansen@linux.intel.com" CC: "hpa@zytor.com" , "ardb@kernel.org" , "david@redhat.com" , "debarbos@redhat.com" , "dzickus@redhat.com" , "jlelli@redhat.com" , =?iso-2022-jp?b?Tk9NVVJBIEpVTklD?= =?iso-2022-jp?b?SEkoGyRCTG5CPCEhPV8wbBsoQik=?= , "kirill.shutemov@linux.intel.com" , "lgoncalv@redhat.com" , "linux-kernel@vger.kernel.org" , "nikunj@amd.com" , "thomas.lendacky@amd.com" Subject: [PATCH 2/2] x86/boot: Add a message about ignored early NMIs Thread-Topic: [PATCH 2/2] x86/boot: Add a message about ignored early NMIs Thread-Index: AQHaVYsrpr7GWJLGak6aXYXtjEM3tQ== Date: Fri, 2 Feb 2024 03:51:58 +0000 Message-ID: <20240202035052.17963-2-junichi.nomura@nec.com> References: <20240202035052.17963-1-junichi.nomura@nec.com> In-Reply-To: <20240202035052.17963-1-junichi.nomura@nec.com> Accept-Language: ja-JP, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.43.0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nec.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYCPR01MB8389:EE_|OS7PR01MB11820:EE_ x-ms-office365-filtering-correlation-id: 6e7ef16f-48bb-4fb9-a587-08dc23a24e2b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: b5hnKD0f/pfqAWD9+PUjLAJ7XJfRhwyUPsknP7WaQC6aPfqUJa0Qv+wTbWXq3M5NENrH/RXlkkcTFe62RWWkEkB+IGvMXcU2ks2DMnUbJQGTfbuzujkluPe4z5zGUbjOkjHYWGEncwbisuieYO2cA1H488VRer1L89Z+qmbH24ZzXtI3K/340Q45yOWfVoQxnuruW83uU0gQPjZ/9Ad5sISVf4Sw7Lltv+cV71rGSCF4U6NUooSJqzXf/B4KfdFaxk4EiNw0NbHTYYGtozRs4wirVNUSMhfDAql909mxgDf+DRyc/LXN4NuIVFAFegRUsPtn9qi0ai4gTZzTYAG4jP1vGol+HS9mM3bjx19Sj9EquM/lI7ijBBQ4IwAs9w33mPtE5SDRqG52162YS+voZ87W8iXpzAkSnQodFTo2+XrQp1rwiXy/K3wgjU4n+QYQ/l70LwtiPDBCkP5h20TG7ecrlcltG6OzH4oGFQ+YQmmq/PHtzmgx/Cx2+6AscLvzAXYvf7+rA0F76KrxBG8HTEU6sfuUwEasqoM4XCsb01saSBmmnedH7bZ6eCPn5dscE7nWRGj7SvZZy5c3WEnWU6rNOA9IXQ8EkaLCttzskRc= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB8389.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(366004)(39860400002)(396003)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(38070700009)(4326008)(66476007)(5660300002)(66946007)(316002)(966005)(478600001)(15650500001)(6486002)(76116006)(66446008)(7416002)(110136005)(83380400001)(54906003)(2616005)(8676002)(6506007)(64756008)(71200400001)(8936002)(66556008)(26005)(2906002)(6512007)(1076003)(122000001)(36756003)(38100700002)(41300700001)(82960400001)(85182001)(86362001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-2022-jp?b?RlR2cHErN2JLaW41RHZO?= =?iso-2022-jp?b?Y3R3cGRzZzA4MWZuWndwNlgvS1R1bjdoUjMyeW00ajZHY25UMXBMQ2xj?= =?iso-2022-jp?b?RWpFTUVoQjJJcVk1VkxQVUE2QzB4eU1UN0U0U3EzU3dzaFhRUGZNaGZG?= =?iso-2022-jp?b?a0JhTXBuTVRCVFhIMXpVMFJRQlZQZHE2djRnZWF1MmJUOXpTVDl1TzVT?= =?iso-2022-jp?b?ZzFKdFdtTkJnUis5ZndOb0Y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p?b?T0JaMTNTWWtianVteWE0c25YaFp6MGNKZXNyYlg1a2wza3RDdnU4ejlN?= =?iso-2022-jp?b?Q2xCcjdVTHlLM3g3akZiQzJkbG02cHU4WDFXMXpzcmxiTkQzY21KanlT?= =?iso-2022-jp?b?QzNjK2lzc3VJbHZnSnNtdWlscnQ5ZTY4azRaYVptNjFKM1VMcXprbFBW?= =?iso-2022-jp?b?ZTlQalZaUnQ0Ym5IZGV1K2ZZQUpNSVZEYy9GdktVdW5lK2MrZy9YN3hK?= =?iso-2022-jp?b?cWQwYjR2VHJNUXkyZjgzR0tmK0k1MlFRZW5BQWtraW9NNTg0SU5wTmN3?= =?iso-2022-jp?b?OFV6ZUlYSTZZTlE9PQ==?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: nec.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB8389.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e7ef16f-48bb-4fb9-a587-08dc23a24e2b X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2024 03:51:58.2669 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: e67df547-9d0d-4f4d-9161-51c6ed1f7d11 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: HLBMSTtYGYQheOBPecpCMHr7lvDT2Kpzjx7NTOReskv2pa12CydL9BJEg+wmuT3yxzsozvELndgRErno3acYCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS7PR01MB11820 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789757757915168800 X-GMAIL-MSGID: 1789757757915168800 Commit 78a509fba9c9 ("x86/boot: Ignore NMIs during very early boot") added an empty handler in early boot stage to avoid boot failure due to spurious NMIs. Add a diagnostic message to show when early NMIs have occurred and/or what happened to them. [ bp: Touchups. ] Suggested-by: Borislav Petkov Suggested-by: H. Peter Anvin Signed-off-by: Jun'ichi Nomura Signed-off-by: Borislav Petkov (AMD) Acked-by: Kirill A. Shutemov Link: https://lore.kernel.org/lkml/20231130103339.GCZWhlA196uRklTMNF@fat_crate.local --- v2 * Moved variable declaration and definition to the right place based on comments from Kirill. No functional changes. v3 * Removed comment and updated message in the NMI handler. * Use error_putdec() helper. diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c --- a/arch/x86/boot/compressed/ident_map_64.c +++ b/arch/x86/boot/compressed/ident_map_64.c @@ -389,5 +389,5 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code) { - /* Empty handler to ignore NMI during early boot */ + spurious_nmi_count++; } diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -52,6 +52,7 @@ struct port_io_ops pio_ops; memptr free_mem_ptr; memptr free_mem_end_ptr; +int spurious_nmi_count; static char *vidmem; static int vidport; @@ -493,6 +494,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output) /* Disable exception handling before booting the kernel */ cleanup_exception_handling(); + if (spurious_nmi_count) { + error_putstr("Spurious early NMIs ignored: "); + error_putdec(spurious_nmi_count); + error_putstr("\n"); + } + return output + entry_offset; } diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -59,6 +59,7 @@ extern char _head[], _end[]; /* misc.c */ extern memptr free_mem_ptr; extern memptr free_mem_end_ptr; +extern int spurious_nmi_count; void *malloc(int size); void free(void *where); void __putstr(const char *s);