Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1371584imu; Wed, 9 Jan 2019 17:19:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xAe2n4Qcmr4DUsCuFvC9bRjC7VywVgk4WWoCwRN8excTtwZezwV/xbbmhJyaHUwwiLRM5 X-Received: by 2002:a63:314d:: with SMTP id x74mr7464304pgx.10.1547083155428; Wed, 09 Jan 2019 17:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547083155; cv=none; d=google.com; s=arc-20160816; b=f8bkVh7fv6bZgOmw05hbB7rRzgFf68GsW0iSRVVtQU1XcOab0mCTQmehsHORKUNoMz Wi1M9aB4TpjqeraX8DVuHTYekY7iz8dVHQrGickOV0xJtD5Hy/idKpEosRGC1rCa/Lnp u21G6VM8jWL4bYGGPo1m5dUO0xnq/voNxZ5LSeXusOOX2WziftRnsZJwlaxu1sIq6AEw 5CAdCFo0OiLOdGhpjwPwbyTgm35Jj/YyL/UKhdi2ZsQpWth7/CPgSZeGolnplJgdGOQq BJTy2FoHa+56r2TAzgaSsEsEdJ0TCDuWjw+bm9VMDt9bFvsEPvC69miUilQTOub/h3wy bvkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=NVZroUDaea7nEdKHuaMh5/82iOSC7MbUhl1sgHAYdn0=; b=GPRIng8WmGiG/Y4sPRF64Ku4ZHZyU9aN2QbUbRpT7BcLjH2JcnOoyQ8el5JH+20mTS b7k+l8AT8IdmF75TeUb5wqPjIWpUshCyeh9feJsCaN433YZCP2nxkyOM4dBcyl8uTcsR M7AR7Br/PV+KrwG8GzfLix12mpFb/pabtsLZl4x/my+MKNYJ//kPI/S5qLLGCKc3G+24 1V5tbwJCeHLbak68OQ1aAqyrTxkVCgXnAJKQtVZNA4ve6UhIyLOxz4q0l8yrz4dxSs4J byI2JukmNfR7xGLUr8pobHSCb/hpqCovsbfWFmdRk0eaNu5W1DXTjwSK1e8EHlg59l+I 3Dhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si6005039pfi.12.2019.01.09.17.19.00; Wed, 09 Jan 2019 17:19:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbfAJBRC (ORCPT + 99 others); Wed, 9 Jan 2019 20:17:02 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:1251 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726458AbfAJBRC (ORCPT ); Wed, 9 Jan 2019 20:17:02 -0500 X-IronPort-AV: E=Sophos;i="5.56,459,1539619200"; d="scan'208";a="51673048" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Jan 2019 09:16:59 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 4D0024B7349D; Thu, 10 Jan 2019 09:16:55 +0800 (CST) Received: from localhost.localdomain (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 10 Jan 2019 09:17:02 +0800 Date: Thu, 10 Jan 2019 09:15:59 +0800 From: Chao Fan To: Borislav Petkov CC: , , , , , , , , , Subject: Re: [PATCH v15 1/6] x86/boot: Copy kstrtoull() to boot/string.c instead of using simple_strtoull() Message-ID: <20190110011559.GB2216@localhost.localdomain> References: <20190107032243.25324-1-fanc.fnst@cn.fujitsu.com> <20190107032243.25324-2-fanc.fnst@cn.fujitsu.com> <20190109124853.GD15665@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20190109124853.GD15665@zn.tnic> User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: 4D0024B7349D.AA0F5 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 09, 2019 at 01:48:53PM +0100, Borislav Petkov wrote: >On Mon, Jan 07, 2019 at 11:22:38AM +0800, Chao Fan wrote: >> Copy kstrtoull() and necessary functions from lib/kstrtox.c to >> boot/string.c so that code in boot/ can use kstrtoull() and the old >> simple_strtoull() can be replaced. >> >> In boot/string.c, using div_u64() from math64.h directly will cause the >> dividend handled as 64-bit value and bring ld error. The solution is to >> separate the dividend to upper and lower in boot/string.o. So copy the >> useful div_u64() and div_u64_rem() to boot/string.c also. To avoid >> redefinition in i386, rename them as __div_u64() and __div_u64_rem(). >> >> Signed-off-by: Chao Fan >> --- >> arch/x86/boot/string.c | 137 +++++++++++++++++++++++++++++++++++++++++ >> arch/x86/boot/string.h | 2 + >> 2 files changed, 139 insertions(+) > >... > >> +static inline char _tolower(const char c) >> +{ >> + return c | 0x20; >> +} >> + >> +const char *_parse_integer_fixup_radix(const char *s, unsigned int *base) > >static Will add it. > >> +{ >> + if (*base == 0) { >> + if (s[0] == '0') { >> + if (_tolower(s[1]) == 'x' && isxdigit(s[2])) >> + *base = 16; >> + else >> + *base = 8; >> + } else >> + *base = 10; >> + } >> + if (*base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') >> + s += 2; >> + return s; >> +} >> + >> +/* >> + * Convert non-negative integer string representation in explicitly given radix >> + * to an integer. >> + * Return number of characters consumed maybe or-ed with overflow bit. >> + * If overflow occurs, result integer (incorrect) is still returned. >> + * >> + * Don't you dare use this function. >> + */ >> +unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p) > >static Will add it. Thanks, Chao Fan > >> +{ >> + unsigned long long res; >> + unsigned int rv; >> + >> + res = 0; >> + rv = 0; >> + while (1) { >> + unsigned int c = *s; >> + unsigned int lc = c | 0x20; /* don't tolower() this line */ >> + unsigned int val; >> + >> + if ('0' <= c && c <= '9') >> + val = c - '0'; >> + else if ('a' <= lc && lc <= 'f') >> + val = lc - 'a' + 10; >> + else >> + break; >> + >> + if (val >= base) >> + break; >> + /* >> + * Check for overflow only if we are within range of >> + * it in the max base we support (16) >> + */ >> + if (unlikely(res & (~0ull << 60))) { >> + if (res > __div_u64(ULLONG_MAX - val, base)) >> + rv |= KSTRTOX_OVERFLOW; >> + } >> + res = res * base + val; >> + rv++; >> + s++; >> + } >> + *p = res; >> + return rv; >> +} > > >-- >Regards/Gruss, > Boris. > >Good mailing practices for 400: avoid top-posting and trim the reply. > >