From nobody Fri Feb 13 17:31:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97559E7D0A2 for ; Thu, 21 Sep 2023 17:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbjIURaB (ORCPT ); Thu, 21 Sep 2023 13:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbjIUR2z (ORCPT ); Thu, 21 Sep 2023 13:28:55 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF17853652 for ; Thu, 21 Sep 2023 10:16:44 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59eb7293017so16451497b3.3 for ; Thu, 21 Sep 2023 10:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695316604; x=1695921404; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=cWVtF+fs1Usi+Rms/xg03923pHwopRJzuckxmMamX6A=; b=n1JDcaLS3QeCXxqU5CrZYcwCXmEFcfnrqvuehEaqvNiQF7jpOB5nLY29f4VmS0PkDj ETajjqf3dD8V6WLGCqG2G2m1I+QuqsMeTXTKE13zrqC/ELYbyXCZvPaWZY1dDRTChBEy lD4cu9ioDYoXZMykyYB2PFN5LNXrupuh1j7sGyysGL8JUDp1FgjIC5F9B1AB0Ldc3udt eRMmRKdwQUsbBdLxrRMAZs3ZjepGksI4XNWVe1VLMukL6RpE3jBnOtdsAHlPwLvm0ra2 jxvH9E04zaF0LHE4dGm780j9/uKyLmTinPVelZKDexPiUuPjiBIHl8YCVnJOP6OeERMT lQIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695316604; x=1695921404; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cWVtF+fs1Usi+Rms/xg03923pHwopRJzuckxmMamX6A=; b=qwNuXDI+c4phzbqX94E45dUUWS83sSK9rykJmfkEHEgwbjz6/8H29h1xy0XgA/LmqV 20NPkzmrEg2FcarHxRoL9C3Vz00vkFdk6svhzP5cxgR7Yt9lYN0/vJUiT2chPVuXv6B2 iBHuskGEJI5lJupEiFbAXA4RecN5cgz2Uvt5JloOIBukectpcFyQ4vwTp1eUWRxSlWBz XPMXf6ui2f71o8O/0o+ZK1dCht+IIC9ANzbW2ZeTYc0chk6Q237K2hWz1H1MRPqs82s/ nHdDhyhpLvQaV2hrObVHM64oTjJqLUoGtCmS3D90sSVBJbcNUqDzt+hRLaKWi48WoDL0 HF7g== X-Gm-Message-State: AOJu0Yx1wVCUTnTdwaRTSEGuSZ8F54znya0hC+rj2lK3RrIvCpiqS+i+ ODvOevv6+BXXWD/TRfKtWrpRFYX3pdg= X-Google-Smtp-Source: AGHT+IF7YpypDgLAEH9RbqQ5ZX2J+3/XnO4CKGwOS3uMOFrTbYjpQET5KdjsfemTXZvMtGJwV7V4Ozr3gzc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b709:0:b0:59b:e669:c944 with SMTP id v9-20020a81b709000000b0059be669c944mr90231ywh.3.1695316603960; Thu, 21 Sep 2023 10:16:43 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 21 Sep 2023 10:16:41 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230921171641.3641776-1-seanjc@google.com> Subject: [PATCH] KVM: selftests: Treat %llx like %lx when formatting guest printf From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Aaron Lewis , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Treat %ll* formats the same as %l* formats when processing printfs from the guest so that using e.g. %llx instead of %lx generates the expected output. Ideally, unexpected formats would generate compile-time warnings or errors, but it's not at all obvious how to actually accomplish that. Alternatively, guest_vsnprintf() could assert on an unexpected format, but since the vast majority of printfs are for failed guest asserts, getting *something* printed is better than nothing. E.g. before =3D=3D=3D=3D Test Assertion Failure =3D=3D=3D=3D x86_64/private_mem_conversions_test.c:265: mem[i] =3D=3D 0 pid=3D4286 tid=3D4290 errno=3D4 - Interrupted system call 1 0x0000000000401c74: __test_mem_conversions at private_mem_conversion= s_test.c:336 2 0x00007f3aae6076da: ?? ??:0 3 0x00007f3aae32161e: ?? ??:0 Expected 0x0 at offset 0 (gpa 0x%lx), got 0x0 and after =3D=3D=3D=3D Test Assertion Failure =3D=3D=3D=3D x86_64/private_mem_conversions_test.c:265: mem[i] =3D=3D 0 pid=3D5664 tid=3D5668 errno=3D4 - Interrupted system call 1 0x0000000000401c74: __test_mem_conversions at private_mem_conversion= s_test.c:336 2 0x00007fbe180076da: ?? ??:0 3 0x00007fbe17d2161e: ?? ??:0 Expected 0x0 at offset 0 (gpa 0x100000000), got 0xcc Fixes: e5119382499c ("KVM: selftests: Add guest_snprintf() to KVM selftests= ") Cc: Aaron Lewis Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/guest_sprintf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/guest_sprintf.c b/tools/testin= g/selftests/kvm/lib/guest_sprintf.c index c4a69d8aeb68..74627514c4d4 100644 --- a/tools/testing/selftests/kvm/lib/guest_sprintf.c +++ b/tools/testing/selftests/kvm/lib/guest_sprintf.c @@ -200,6 +200,13 @@ int guest_vsnprintf(char *buf, int n, const char *fmt,= va_list args) ++fmt; } =20 + /* + * Play nice with %llu, %llx, etc. KVM selftests only support + * 64-bit builds, so just treat %ll* the same as %l*. + */ + if (qualifier =3D=3D 'l' && *fmt =3D=3D 'l') + ++fmt; + /* default base */ base =3D 10; =20 base-commit: 7c7cce2cf7ee2ac54851ba1fbcf0e968932e32b9 --=20 2.42.0.515.g380fc7ccd1-goog