Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1682468imm; Thu, 14 Jun 2018 02:00:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJZTn3YG1TKzVlvHEiHEW9xxAYvGgrVusIIlX6lRVvJRDKfaEeo5Gcbnp8gSAYBcCenLRV6 X-Received: by 2002:a17:902:4301:: with SMTP id i1-v6mr2053482pld.280.1528966836238; Thu, 14 Jun 2018 02:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528966836; cv=none; d=google.com; s=arc-20160816; b=FNjCNnAishD0CYyPbTTl1lDReOdZee3w8YOhQG+m2eqCGDd5hn21Yjv8+ZAaMyUiL9 BNPhGvxfqVRDXR2gCQiXXXKoDRCW0urbL00Kh3zoAdKPXMXGUISq2+Mrbc5tW5p66rKt RhN+Yzkir8FvIdv18XAjnnU9pc2gYmnsov79j21Y1Se4TuZDEf8cB8cgUCcLVbDEJLsj 4+HKIS/csIuUzkUc280RoPtOC1oXTTudjslwaO8xsd2XFWt/m9eALrOMCm7bNI5kJopu h+IKYA4hVLNDUAb6kMWS8XyBTKD+8GoSMdXFVcoLVxXPJFSfUoHkjtO/xaOW+e/MwnTC jSdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=F8qEJPDDDWpumXfNh8L/chH9OAKqoNRjsTxbrjqq4M4=; b=lo3kyooL26Wf0aOdGfxLwPdA2WimNLXOU2h7Rprcf7nHtLsCLFvPYt5uVacr4LzHCj taX2idxoOkGNtgE/8UcnD+/E3f6iBfEQoIxZuk+cP+uM5SLGt8fRN3fVopSW6Ke3/4rv l2e7Rm25+1igxazJwso8b+EkGTnAvJktdhyrKqLlt137ScfgwAkeYVDvg2tvRJpt3ZFe A0UHf0ZjZlthr+On6NcgNXE52TWtuirOz3PYoV4wZlCjF5TeyQRsCxC3daK4PhWIxqts vFjrdjixMKq0NlMktVOAIKglgmgQBXK3FnqYTDDLte87kaYoi2rq0W+v3xrDl953s5UA 2ZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VdldeZBb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si4758252plc.346.2018.06.14.02.00.21; Thu, 14 Jun 2018 02:00:36 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VdldeZBb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754762AbeFNI75 (ORCPT + 99 others); Thu, 14 Jun 2018 04:59:57 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:46124 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581AbeFNI7z (ORCPT ); Thu, 14 Jun 2018 04:59:55 -0400 Received: by mail-vk0-f66.google.com with SMTP id b134-v6so3190916vke.13 for ; Thu, 14 Jun 2018 01:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=F8qEJPDDDWpumXfNh8L/chH9OAKqoNRjsTxbrjqq4M4=; b=VdldeZBbyKWiaLHEUXzx7uA3189lEECo/kUbFEAQHHdyx4XbnkKVDe0ZKev7rckga+ 72oZ5+jClU99IrEK38i49JzMBqGtLrjt0OyATOQ5GFUAiOBjnU6KMglEYpfVbyRNsWV/ fnRtHE4AIQjmeviU1YpzFHaBZn6/3p28wW2UQKuIJEEDtR1wVUTpSrO7reU2RuwOsMzE +gDU1MQN98nTyMyP+ZoZ58sDEjy/nsGOnEMSxsN0+0Zf4OJmJ8KNZpxBv2Klq4fT9gZp MkgFQ0oab98k+jxv695d5fPVR8JR2oA+Njpnn1KCna8RPPA8LKwDI/97FZo4r58OwdqX Mo3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=F8qEJPDDDWpumXfNh8L/chH9OAKqoNRjsTxbrjqq4M4=; b=fBlrRo3TyHFj1nUXpdUKyh/pyo2UUB+FD407MXqIh/1Oex3gv4of+JVCNdxa+leroX mPpWN+7rcEC1G6QMXQ1Na68XCgKagl1L91H3Uh39RTz1dX+vfLH25KVxKWmAZN9Q3oJw hzZxWmpCi7wZwUpWSGusFTNukkBXffyhrYU1vjaw7YsvrAnMnydcZk3SqCjJQxz8w+Hb hahgO0F+N+oIt5T4Emdu3CgtTl3h/umCZwZtiH8fhHkYZnu5HftbZAFj1ON3Gi+zRLr+ GIMFO9+gPF8KTpvEQeNv8HrpKCKV8V/nZf6G8Ht6q8j0MdZpRcepCCNYJka5pP1qUqKw YrgQ== X-Gm-Message-State: APt69E3ESlsBEVfaDs8bGgSjtPfP0miMGm/HUmeRWb21MR8h4D42RiCw yDR7d9y0YOMrGUXjG5Jy6Q2A3O519RvY7IHRbX6oSQ== X-Received: by 2002:a1f:7283:: with SMTP id n125-v6mr999781vkc.26.1528966794706; Thu, 14 Jun 2018 01:59:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:8b02:0:0:0:0:0 with HTTP; Thu, 14 Jun 2018 01:59:54 -0700 (PDT) In-Reply-To: <20180613171840.29827-1-thierry.escande@linaro.org> References: <20180613171840.29827-1-thierry.escande@linaro.org> From: Andy Shevchenko Date: Thu, 14 Jun 2018 11:59:54 +0300 Message-ID: Subject: Re: [PATCH v3] lib/test_printf.c: accept "ptrval" as valid result for plain 'p' tests To: Thierry Escande Cc: Andrew Morton , David Miller , Petr Mladek , Rasmus Villemoes , "Tobin C . Harding" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 13, 2018 at 8:18 PM, Thierry Escande wrote: > If the test_printf module is loaded before the crng is initialized, the > plain 'p' tests will fail because the printed address will not be hashed > and the buffer will contain "(____ptrval____)" or "(ptrval)" instead > (64-bit vs 32-bit). > Since we cannot wait for the crng to be initialized for an undefined > time, both plain 'p' tests now accept the strings "(____ptrval____)" or > "(ptrval)" as a valid result and print a warning message. > LGTM. Reviewed-by: Andy Shevchenko > Signed-off-by: Thierry Escande > --- > > Changes in v3: > - Use "(____ptrval____)" for 64-bit > - Update commit message headline > > Changes in v2: > - Remove wait_for_random_bytes() usage > - Remove Acked-by from Tobin as the proposed solution is not the same > anymore. > > lib/test_printf.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/lib/test_printf.c b/lib/test_printf.c > index 71ebfa43ad05..31f00b8ca657 100644 > --- a/lib/test_printf.c > +++ b/lib/test_printf.c > @@ -206,6 +206,7 @@ test_string(void) > #define PTR_WIDTH 16 > #define PTR ((void *)0xffff0123456789ab) > #define PTR_STR "ffff0123456789ab" > +#define PTR_VAL_NO_CRNG "(____ptrval____)" > #define ZEROS "00000000" /* hex 32 zero bits */ > > static int __init > @@ -216,7 +217,16 @@ plain_format(void) > > nchars = snprintf(buf, PLAIN_BUF_SIZE, "%p", PTR); > > - if (nchars != PTR_WIDTH || strncmp(buf, ZEROS, strlen(ZEROS)) != 0) > + if (nchars != PTR_WIDTH) > + return -1; > + > + if (strncmp(buf, PTR_VAL_NO_CRNG, PTR_WIDTH) == 0) { > + pr_warn("crng possibly not yet initialized. plain 'p' buffer contains \"%s\"", > + PTR_VAL_NO_CRNG); > + return 0; > + } > + > + if (strncmp(buf, ZEROS, strlen(ZEROS)) != 0) > return -1; > > return 0; > @@ -227,6 +237,7 @@ plain_format(void) > #define PTR_WIDTH 8 > #define PTR ((void *)0x456789ab) > #define PTR_STR "456789ab" > +#define PTR_VAL_NO_CRNG "(ptrval)" > > static int __init > plain_format(void) > @@ -245,7 +256,16 @@ plain_hash(void) > > nchars = snprintf(buf, PLAIN_BUF_SIZE, "%p", PTR); > > - if (nchars != PTR_WIDTH || strncmp(buf, PTR_STR, PTR_WIDTH) == 0) > + if (nchars != PTR_WIDTH) > + return -1; > + > + if (strncmp(buf, PTR_VAL_NO_CRNG, PTR_WIDTH) == 0) { > + pr_warn("crng possibly not yet initialized. plain 'p' buffer contains \"%s\"", > + PTR_VAL_NO_CRNG); > + return 0; > + } > + > + if (strncmp(buf, PTR_STR, PTR_WIDTH) == 0) > return -1; > > return 0; > -- > 2.14.1 > -- With Best Regards, Andy Shevchenko