From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6240EC433E0 for ; Fri, 5 Jun 2020 10:28:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29D3F2074B for ; Fri, 5 Jun 2020 10:28:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Z/kS8PMk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29D3F2074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh9a8-0004MY-DV for qemu-devel@archiver.kernel.org; Fri, 05 Jun 2020 06:28:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh9X8-0008SO-B5 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 06:25:06 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:45287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jh9X5-0006ps-HJ for qemu-devel@nongnu.org; Fri, 05 Jun 2020 06:25:05 -0400 Received: by mail-wr1-x444.google.com with SMTP id c3so9159766wru.12 for ; Fri, 05 Jun 2020 03:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=3FD/zOHKmvX65oEOsFJTgPzFn5yTKCVq+fGQN8ygRsg=; b=Z/kS8PMkvCWdTxTzDifIoFhCMN/oyRYjDFNlVgpWdjK+lKE4BoGsH2HmbqC3Z11dFa eqesTwmsUe8VBKMGsxbrzD0BbdGF+32VT2niKtKcCLDXcK8P5YpzWWBeQpACn1sdBEVK 4mRck4z3pnC7Z+jnSR1iIopxDAdS4jrNRoUNl7v63mi2pfcn0Krvq1Ned8qCymMEdRRq 35Cd+LBHRxIOtlJYb6+kd3gkYQ4k0W2411Ig7CaHob9kvDoLU/hTavMbJ4k0vQ1Z9sG1 3UoyCGfqVcc+bL5kiKzxc08akDLpkTpDEtiUnAsIbNX59MXurLP4hKW/gZ8/Cnddrd18 pHzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=3FD/zOHKmvX65oEOsFJTgPzFn5yTKCVq+fGQN8ygRsg=; b=Q9UFkZCEgqtlXDbY75WWNQvc3NUmhdBNOYDaOuPAdZ5n8A1QFo1Zx5n8lE3P7zWvoV S6ZSK4mTPKqFcCfJJZTKUi5T3QDLo7WhYbybkMUeZWPeeidtnfXnenNAIfX70RiAeoo9 AKgNMjiwbQmHNV9ExHwivUb7ievM39/gz8YS0UYDfh2Wwe3nolAHvPYjdujyQkjutdLu y0vUgsXvTkf9ZhjFWpdCxnec9BGljaFMHaRPYRD9zVLbezS/JX1Vk3ciawze09LSh9z6 Rx2rVQbkFGqHnTIuhOm5Ks/aVccS3vspE5dqiYVRIOnfC26OOxFg7ZDz1iMsuOpxuBfq l4eA== X-Gm-Message-State: AOAM531PQpALHdVCU3GMp7yEub9bLcGZlcCaacyO6cr4myWfXFolYRbc JBG/qT7rm9QxoNYhqOtALiKHTw== X-Google-Smtp-Source: ABdhPJx4FseI/kyqICyRgpEW0CFGwUWGXbdFDFhZGsa+TovM4XuSvO0YwRkKc1svh7k8o0wb0pVRlw== X-Received: by 2002:adf:bb4f:: with SMTP id x15mr8499930wrg.332.1591352701224; Fri, 05 Jun 2020 03:25:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u4sm11422002wmb.48.2020.06.05.03.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 03:24:59 -0700 (PDT) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 155BD1FF7E; Fri, 5 Jun 2020 11:24:59 +0100 (BST) References: <20200527100546.29297-1-alex.bennee@linaro.org> <20200527100546.29297-3-alex.bennee@linaro.org> <355ff6ba-ed8a-bc1e-4b74-c87a532e47bd@linaro.org> <87tuzp4zhx.fsf@linaro.org> User-agent: mu4e 1.5.1; emacs 28.0.50 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Richard Henderson Subject: Re: [PATCH v1 2/3] linux-user: deal with address wrap for ARM_COMMPAGE on 32 bit In-reply-to: <87tuzp4zhx.fsf@linaro.org> Date: Fri, 05 Jun 2020 11:24:59 +0100 Message-ID: <87k10l4xok.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bug 1880225 <1880225@bugs.launchpad.net>, Riku Voipio , qemu-devel@nongnu.org, Laurent Vivier , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Alex Benn=C3=A9e writes: > Richard Henderson writes: > >> On 5/27/20 3:05 AM, Alex Benn=C3=A9e wrote: >>> @@ -2145,7 +2145,7 @@ static uintptr_t pgd_find_hole_fallback(uintptr_t= guest_size, uintptr_t brk, lon >>>=20=20 >>> /* Return value for guest_base, or -1 if no hole found. */ >>> static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest= _size, >>> - long align) >>> + long align, uintptr_t offset) >>> { >>> GSList *maps, *iter; >>> uintptr_t this_start, this_end, next_start, brk; >>> @@ -2171,7 +2171,7 @@ static uintptr_t pgb_find_hole(uintptr_t guest_lo= addr, uintptr_t guest_size, >>>=20=20 >>> this_end =3D ((MapInfo *)iter->data)->start; >>> next_start =3D ((MapInfo *)iter->data)->end; >>> - align_start =3D ROUND_UP(this_start, align); >>> + align_start =3D ROUND_UP(this_start + offset, align); >>>=20=20 >>> /* Skip holes that are too small. */ >> >> I suppose offset is supposed to mean we start from -offset? > > Well guest_base will start higher meaning we have space for the > commpage beneath it. > >> You didn't update >> pgb_find_hole_fallback. > > Fixed. > >> >>> - loaddr =3D ARM_COMMPAGE & -align; >>> + offset =3D (128 * KiB); >> >> Why 128K? Surely this should be an expression against ARM_COMMPAGE. > > In theory: > > offset =3D -(ARM_COMMPAGE & -align); > > should do the trick but I found it failed every now and again. > Frustratingly putting printfs in made it go away so in frustration I > just upped the offset until it stopped happening. > > I do kinda wish rr worked on i386 :-/ Ahh all I needed was a MAP_FIXED for init_commpage --=20 Alex Benn=C3=A9e From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A1EBC433E0 for ; Fri, 5 Jun 2020 10:33:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2B462074B for ; Fri, 5 Jun 2020 10:33:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2B462074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bugs.launchpad.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh9fU-0001tm-4i for qemu-devel@archiver.kernel.org; Fri, 05 Jun 2020 06:33:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jh9cf-0008VZ-H8 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 06:30:49 -0400 Received: from indium.canonical.com ([91.189.90.7]:59006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jh9cd-00087K-T5 for qemu-devel@nongnu.org; Fri, 05 Jun 2020 06:30:49 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.86_2 #2 (Debian)) id 1jh9cc-0007Eq-0V for ; Fri, 05 Jun 2020 10:30:46 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 01FDD2E80E7 for ; Fri, 5 Jun 2020 10:30:46 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Fri, 05 Jun 2020 10:24:59 -0000 From: =?utf-8?q?Alex_Benn=C3=A9e?= <1880225@bugs.launchpad.net> To: qemu-devel@nongnu.org X-Launchpad-Notification-Type: bug X-Launchpad-Bug: product=qemu; status=In Progress; importance=Undecided; assignee=alex.bennee@linaro.org; X-Launchpad-Bug-Tags: arm testcase X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: ajbennee aleksandar-markovic X-Launchpad-Bug-Reporter: Aleksandar Markovic (aleksandar-markovic) X-Launchpad-Bug-Modifier: =?utf-8?q?Alex_Benn=C3=A9e_=28ajbennee=29?= References: <159017301531.7966.9120113243897778171.malonedeb@gac.canonical.com> <87tuzp4zhx.fsf@linaro.org> Message-ID: <87k10l4xok.fsf@linaro.org> Subject: [Bug 1880225] Re: [PATCH v1 2/3] linux-user: deal with address wrap for ARM_COMMPAGE on 32 bit X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml X-Launchpad-Message-For: qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="ef9fc486e875d54078fa61cf91e898b895125d89"; Instance="production-secrets-lazr.conf" X-Launchpad-Hash: bed74dea52b3f87d6acfe9e57561dacb841c7296 Received-SPF: none client-ip=91.189.90.7; envelope-from=bounces@canonical.com; helo=indium.canonical.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/05 04:10:55 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -65 X-Spam_score: -6.6 X-Spam_bar: ------ X-Spam_report: (-6.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bug 1880225 <1880225@bugs.launchpad.net> Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20200605102459.JvmSILQ9cS2nZ1sXv7xpNF-YNM57-6I2W3FCXrBXyjc@z> Alex Benn=C3=A9e writes: > Richard Henderson writes: > >> On 5/27/20 3:05 AM, Alex Benn=C3=A9e wrote: >>> @@ -2145,7 +2145,7 @@ static uintptr_t pgd_find_hole_fallback(uintptr_t= guest_size, uintptr_t brk, lon >>> = >>> /* Return value for guest_base, or -1 if no hole found. */ >>> static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest= _size, >>> - long align) >>> + long align, uintptr_t offset) >>> { >>> GSList *maps, *iter; >>> uintptr_t this_start, this_end, next_start, brk; >>> @@ -2171,7 +2171,7 @@ static uintptr_t pgb_find_hole(uintptr_t guest_lo= addr, uintptr_t guest_size, >>> = >>> this_end =3D ((MapInfo *)iter->data)->start; >>> next_start =3D ((MapInfo *)iter->data)->end; >>> - align_start =3D ROUND_UP(this_start, align); >>> + align_start =3D ROUND_UP(this_start + offset, align); >>> = >>> /* Skip holes that are too small. */ >> >> I suppose offset is supposed to mean we start from -offset? > > Well guest_base will start higher meaning we have space for the > commpage beneath it. > >> You didn't update >> pgb_find_hole_fallback. > > Fixed. > >> >>> - loaddr =3D ARM_COMMPAGE & -align; >>> + offset =3D (128 * KiB); >> >> Why 128K? Surely this should be an expression against ARM_COMMPAGE. > > In theory: > > offset =3D -(ARM_COMMPAGE & -align); > > should do the trick but I found it failed every now and again. > Frustratingly putting printfs in made it go away so in frustration I > just upped the offset until it stopped happening. > > I do kinda wish rr worked on i386 :-/ Ahh all I needed was a MAP_FIXED for init_commpage -- = Alex Benn=C3=A9e -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1880225 Title: Emulation of some arm programs fail with "Assertion `have_guest_base' failed." Status in QEMU: In Progress Bug description: This issue is observer with QEMU ToT, checked out around May 15th (but I believe it is present in current master too), and wasn't present in QEMU v5.0.0. I am using 32-bit Intel(R) Pentium(R) M processor 1.73GHz host. Arm cross-compiler is a standard cross-compiler that comes with Debian-based distributions, and gcc version is: $ arm-linux-gnueabi-gcc --version arm-linux-gnueabi-gcc (Debian 8.3.0-2) 8.3.0 Compile this program with cross compiler: $ arm-linux-gnueabi-gcc -O2 -static toupper_string.c -o toupper_string-arm Emulation with QEMU v5.0.0 is correct, and gives expected output: $ ~/Build/qemu-5.0.0/build-gcc/arm-linux-user/qemu-arm ./toupper_string-a= rm CONTROL RESULT: (toupper_string) nwlrbbmqbhcdarz owkkyhiddqscdxr jmowfrxsjybldbe fsarcbynecdyggx xpklorel= lnmpapq NWLRBBMQBHCDARZ OWKKYHIDDQSCDXR JMOWFRXSJYBLDBE FSARCBYNECDYGGX XPKLOREL= LNMPAPQ While, in case of QEMU master it fails: $ ~/Build/qemu-master/build-gcc/arm-linux-user/qemu-arm ./toupper_string-= arm qemu-arm: /home/rtrk/Build/qemu-master/linux-user/elfload.c:2294: probe_g= uest_base: Assertion `have_guest_base' failed. Aborted There are many other programs that exibit the same behavior. The failure is arm-sprecific. = ----------------------------------------------------- source code: (let's call this file toupper_string.c) (similar file is also in attachment) = #include #include #include #include = #define MAX_STRING_LENGHT 15 #define NUMBER_OF_RANDOM_STRINGS 100 #define DEFAULT_NUMBER_OF_REPETITIONS 30000 #define MAX_NUMBER_OF_REPETITIONS 1000000000 #define NUMBER_OF_CONTROL_PRINT_ITEMS 5 /* Structure for keeping an array of strings */ struct StringStruct { char chars[MAX_STRING_LENGHT + 1]; }; /** * Sets characters of the given string to random small letters a-z. * @param s String to get random characters. * @len Length of the input string. */ static void gen_random_string(char *chars, const int len) { static const char letters[] =3D "abcdefghijklmnopqrstuvwxyz"; for (size_t i =3D 0; i < len; i++) { chars[i] =3D letters[rand() % (sizeof(letters) - 1)]; } chars[len] =3D 0; } void main (int argc, char* argv[]) { struct StringStruct random_strings[NUMBER_OF_RANDOM_STRINGS]; struct StringStruct strings_to_be_uppercased[NUMBER_OF_RANDOM_STRINGS= ]; int32_t number_of_repetitions =3D DEFAULT_NUMBER_OF_REPETITIONS; int32_t option; /* Parse command line options */ while ((option =3D getopt(argc, argv, "n:")) !=3D -1) { if (option =3D=3D 'n') { int32_t user_number_of_repetitions =3D atoi(optarg); /* Check if the value is a negative number */ if (user_number_of_repetitions < 1) { fprintf(stderr, "Error ... Value for option '-n' cannot b= e a " "negative number.\n"); exit(EXIT_FAILURE); } /* Check if the value is a string or zero */ if (user_number_of_repetitions =3D=3D 0) { fprintf(stderr, "Error ... Invalid value for option '-n'.= \n"); exit(EXIT_FAILURE); } /* Check if the value is too large */ if (user_number_of_repetitions > MAX_NUMBER_OF_REPETITIONS) { fprintf(stderr, "Error ... Value for option '-n' cannot b= e " "more than %d.\n", MAX_NUMBER_OF_REPETITI= ONS); exit(EXIT_FAILURE); } number_of_repetitions =3D user_number_of_repetitions; } else { exit(EXIT_FAILURE); } } /* Create an array of strings with random content */ srand(1); for (size_t i =3D 0; i < NUMBER_OF_RANDOM_STRINGS; i++) { gen_random_string(random_strings[i].chars, MAX_STRING_LENGHT); } /* Perform uppercasing of a set of random strings multiple times */ for (size_t j =3D 0; j < number_of_repetitions; j++) { /* Copy initial set of random strings to the set to be uppercased= */ memcpy(strings_to_be_uppercased, random_strings, NUMBER_OF_RANDOM_STRINGS * (MAX_STRING_LENGHT + 1)); /* Do actual changing case to uppercase */ for (size_t i =3D 0; i < NUMBER_OF_RANDOM_STRINGS; i++) { int k =3D 0; = while (strings_to_be_uppercased[i].chars[k]) { = char ch =3D strings_to_be_uppercased[i].chars[k] - 32; = memcpy((void *)strings_to_be_uppercased[i].chars + k, &ch, 1); k++; = } = } } /* Control printing */ printf("CONTROL RESULT: (toupper_string)\n"); for (size_t i =3D 0; i < NUMBER_OF_CONTROL_PRINT_ITEMS; i++) { printf(" %s", random_strings[i].chars); } printf("\n"); for (size_t i =3D 0; i < NUMBER_OF_CONTROL_PRINT_ITEMS; i++) { printf(" %s", strings_to_be_uppercased[i].chars); } printf("\n"); } To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1880225/+subscriptions