From patchwork Tue Feb 6 10:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 197295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1433458dyb; Tue, 6 Feb 2024 02:02:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn2Dd9fM7sFYHh+totH6nid/LQ+YAnPcBwTKniN4ZSb/1taciInKzDw8NSxtOOuQ4r6PnA X-Received: by 2002:aa7:d893:0:b0:55f:e543:b006 with SMTP id u19-20020aa7d893000000b0055fe543b006mr2331533edq.13.1707213764025; Tue, 06 Feb 2024 02:02:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707213764; cv=pass; d=google.com; s=arc-20160816; b=P67S26wFq8jlxmt1/fbFNLfaFH3j9mSmv0OobDgd5/g44frCYBHzdTDMocgflP/v3j HkiDAucip/meDgteap7tsAcGicchg2EtRA/B++zWjq16CJGlXIovfSimfJHwKm4JQZ4N jyihdYZP0D2I87hVEUAwsdLwM4dyFPXaUcOwm8Jx4fRH7TQ07+ejFBZgPpV72nb/b+4z XRScOsx/trbIKpISzEQ12ctWGmAyyd2aYrquzcDYdv8dGZEdSpQ6eqLocWITXaRqU4+g Ejx8eVFg05XfaiNFhKwUcroRUYUrCFz9646pb0i/S7Asofa/e/QPEtF7eUAP/bEdSe// cQ6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=7dEABDVhmMXvMgmsdoO0NeZE5wZSIifSNPNzi2/mS34=; fh=mKWa0liN1G9vKw4gVWRFU4KR1YEE7KVh/3M0Jj+DZU4=; b=Y5K8HxdxTER9lilp3W5Y2Jr36l2wXeHNdXjXCWuaj9GAVuMj5MV+G1yPgrrrJJO7oE ua0SS2KBPnFGKasgD7vFeFRVnFbpMNX4uVCIvye8XZ7zhFHeSOYGg4ixwZzZpHCKlg9z 9ynA4Prt+D8y3k/nIZmlvGUlvStRpWu9ui3ZfAKq9cs5HuUxL7ZjIn4TKNjd/OvVz2Et X3YNDm++vtwucE/qvYqy6RMEjwmUinNesFolbet6U9FePjRMVLhQZPQEuGVAweGoM8Rg vC5Zwq9xopuATk/dvP0bSQ8mQmA5KQAHjPWgvlSJYhSGtDB7PVEUNkhMJCfDs4iNcaaw gbqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Aor5CPkW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-54640-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54640-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCWVuRfzGEQ3Q3MtAtYixwlqBS2QDcIFDpdtPOJG39zM6xBAR9dP34ZlcdszipPXe4TLBeh00LSdA8FCKJNqS0EZln6RJg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n19-20020a5099d3000000b005600463837bsi940887edb.543.2024.02.06.02.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 02:02:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54640-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=@linutronix.de header.s=2020 header.b=Aor5CPkW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-54640-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54640-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 4C0A01F23866 for ; Tue, 6 Feb 2024 10:02:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1512312E1EE; Tue, 6 Feb 2024 10:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Aor5CPkW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PkLk1BkH" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8521E12D153; Tue, 6 Feb 2024 10:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707213726; cv=none; b=u20rJzB6pfVlujBJmXx4dTYal1tFkB55HRdNYl9JDWkzQHqeDKNop4VFU+12Wu+hI2ADqYi4V1CzW2D/8bv/VyyNLaXoS2n7Su0paY5NehNVXqCzU3iUptxQVr2WNRHp9mmfwaU7pKmqL3sJg0YFP6LCWM4msjO+Ckeyna5Ayb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707213726; c=relaxed/simple; bh=NfP+FevxDuBK8udXH4wEzkmPr6LHcRF94FOoTA7ST+k=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Jd1npnykcHZpSGTi7YPYgyVL6MvOC9cnaaiZM5GO4irtJmmyorSDdXzxJZKSPASgUMsMUwtct5YYSSVD3VRxV0InS+59CW3B0fr5TIrrKsks1RKkPCoN4RwIbegSlzmqGpAoaNrVmDPlv0P/TuCsoVfGPiiIuera5AJgX6PQIVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Aor5CPkW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PkLk1BkH; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 06 Feb 2024 10:01:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707213717; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7dEABDVhmMXvMgmsdoO0NeZE5wZSIifSNPNzi2/mS34=; b=Aor5CPkWIsuEOunzGsZdyco2B2fG0MDOsK55Z2HabDQ8v7ukEEIXlQX+lPndFQpMpXA3qe 162MihGQJmdYqtam/GFSOeZMQT2vtXo3aLSKMy/AEl2RVy78OnlMs8ZOOGtg6x93i/od8S P22263147fFOg4GQeuNAw7EqJWAxfnU4vtx+boCVIfwCv0nN+hd7l0AtoX/+jSPT1HTwDg ail9jzMRVoTWJnGXs6CZsSt9wddBXrd++sk+jzT/hKkfUV/fSXzK0m60McrX/e0pjY/iRU XPL1bKJMYv3HYOeleELXsUH5UQaNY2BiGHVQRc6CuvSTIwORsvAiTWu692hVsg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707213717; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7dEABDVhmMXvMgmsdoO0NeZE5wZSIifSNPNzi2/mS34=; b=PkLk1BkHud9CJOo/HC2FSyju45aHJo5by3ZTQ2iOlxuk1RZqbdYRMpAmlH4vXivjngroAx W0tvoWA+0G8QkXCQ== From: "tip-bot2 for H. Peter Anvin" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/boot] x86/boot: Add error_putdec() helper Cc: "Borislav Petkov (AMD)" , "H. Peter Anvin (Intel)" , "Jun'ichi Nomura" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240202035052.17963-1-junichi.nomura@nec.com> References: <20240202035052.17963-1-junichi.nomura@nec.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170721371655.398.8075896700527309763.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789757671740302078 X-GMAIL-MSGID: 1790143379581423134 The following commit has been merged into the x86/boot branch of tip: Commit-ID: 9ba8ec8ee67a00eb5631364e4b716f35559724d4 Gitweb: https://git.kernel.org/tip/9ba8ec8ee67a00eb5631364e4b716f35559724d4 Author: H. Peter Anvin AuthorDate: Fri, 02 Feb 2024 03:51:43 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 06 Feb 2024 10:50:21 +01:00 x86/boot: Add error_putdec() helper 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 Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/lkml/20240123112624.GBZa-iYP1l9SSYtr-V@fat_crate.local/ Link: https://lore.kernel.org/r/20240202035052.17963-1-junichi.nomura@nec.com --- arch/x86/boot/compressed/misc.c | 33 ++++++++++++++++++++++---------- arch/x86/boot/compressed/misc.h | 2 ++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index b99e08e..bf2aac4 100644 --- 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 index bc2f0f1..6502bc6 100644 --- 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