Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5767761ybi; Wed, 31 Jul 2019 03:03:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBeh5RS2foyiLyQ/jVZoJGfk2lAyT5IX8Uunhl8kVk5oUoEFKFCuVSHNfbtS94inZYc0Ss X-Received: by 2002:a63:d301:: with SMTP id b1mr105107118pgg.379.1564567392186; Wed, 31 Jul 2019 03:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564567392; cv=none; d=google.com; s=arc-20160816; b=mzbzKtLqsAcOHCkCF8YWVvfz+4x3hlxIudw/gA7ysFZ/vMqq/z93s9i0B7ZE/Mtdtv WlyA30EzDvETpbsrJYmrVIGaOzV+WqJExu4IQC4yDXaAKwZVlRtHJgh6hwlv0d87KIzB 27vui+4BQUHlMmmskWsSOZ4dAGvHbx1xLK1eRmvE0Cu1Y8SG6vGz1Bx10wpKi+OHyEqh J2eI3+MG91noLXNjfIDXS/kVpJ16yBAv/u+16H+Cyw1lwpzDq8uGLbhzsafDWrr/YkCS NXQHJ/5L24eoDq0pDF+wTLo9FBulFM0orH2OnNHNHM90pzg05E8GGL96daJP1eWK8q8W 5tsg== 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=+v3nIgtk6WEQAjylfSpcTmlWh5n10E4QxHPEawuytP0=; b=FW8SFpuYhsEZaLVMX7JS7YKN3fjZsCvxzEBTG17X/YjURldw40lQARDEksC/LiQW+p KuHC/eJryuiNwhKO5zE8vyg6imbcw3ONcVf6tELwnpTvA4T++TV3/YfEYqOb6hFItJMM R0aUAa3cgyBBSGu81y/Lov/hQRUR26zWvF7o5wpoV/Zr/1biVrYK5OBEEIrwc4I6OyJr OQ69NfKVFee/uPAmPlb1fCRdAeZxTafUaK7pvI5qH7rD8ZT4oOhkfPKwX6WPwYAo397P I8UiLyqsrlEWSh6Eon8GhTQSZsK3DdkratExSOHBwH1y/X/e4OOR4r5NSbfx9Oliua4J qrtw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si30034510plf.368.2019.07.31.03.02.49; Wed, 31 Jul 2019 03:03:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726966AbfGaIoR (ORCPT + 99 others); Wed, 31 Jul 2019 04:44:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38484 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbfGaIoR (ORCPT ); Wed, 31 Jul 2019 04:44:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62E3B883D7; Wed, 31 Jul 2019 08:44:16 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64BEF1001281; Wed, 31 Jul 2019 08:44:07 +0000 (UTC) Date: Wed, 31 Jul 2019 10:44:05 +0200 From: Andrew Jones To: Thomas Huth Cc: kvm@vger.kernel.org, Christian Borntraeger , Janosch Frank , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, David Hildenbrand , Cornelia Huck , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Shuah Khan , Peter Xu Subject: Re: [PATCH 2/2] KVM: selftests: Enable dirty_log_test on s390x Message-ID: <20190731084405.tn3x6nmt2svkjkiq@kamzik.brq.redhat.com> References: <20190730100112.18205-1-thuth@redhat.com> <20190730100112.18205-3-thuth@redhat.com> <20190730105721.z4zsul7uxl2igoue@kamzik.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 Jul 2019 08:44:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 10:19:57AM +0200, Thomas Huth wrote: > On 30/07/2019 12.57, Andrew Jones wrote: > > On Tue, Jul 30, 2019 at 12:01:12PM +0200, Thomas Huth wrote: > >> To run the dirty_log_test on s390x, we have to make sure that we > >> access the dirty log bitmap with little endian byte ordering and > >> we have to properly align the memslot of the guest. > >> Also all dirty bits of a segment are set once on s390x when one > >> of the pages of a segment are written to for the first time, so > >> we have to make sure that we touch all pages during the first > >> iteration to keep the test in sync here. > >> > >> Signed-off-by: Thomas Huth > >> --- > [...] > >> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c > >> index ceb52b952637..7a1223ad0ff3 100644 > >> --- a/tools/testing/selftests/kvm/dirty_log_test.c > >> +++ b/tools/testing/selftests/kvm/dirty_log_test.c > >> @@ -26,9 +26,22 @@ > >> /* The memory slot index to track dirty pages */ > >> #define TEST_MEM_SLOT_INDEX 1 > >> > >> +#ifdef __s390x__ > >> + > >> +/* > >> + * On s390x, the ELF program is sometimes linked at 0x80000000, so we can > >> + * not use 0x40000000 here without overlapping into that region. Thus let's > >> + * use 0xc0000000 as base address there instead. > >> + */ > >> +#define DEFAULT_GUEST_TEST_MEM 0xc0000000 > > > > I think both x86 and aarch64 should be ok with this offset. If testing > > proves it does, then we can just change it for all architecture. > > Ok. It seems to work on x86 - could you please check aarch64, since I > don't have such a system available right now? Tested it. It works on aarch64 too. > > >> +/* Dirty bitmaps are always little endian, so we need to swap on big endian */ > >> +#if defined(__s390x__) > >> +# define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) > >> +# define test_bit_le(nr, addr) \ > >> + test_bit((nr) ^ BITOP_LE_SWIZZLE, addr) > >> +# define set_bit_le(nr, addr) \ > >> + set_bit((nr) ^ BITOP_LE_SWIZZLE, addr) > >> +# define clear_bit_le(nr, addr) \ > >> + clear_bit((nr) ^ BITOP_LE_SWIZZLE, addr) > >> +# define test_and_set_bit_le(nr, addr) \ > >> + test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, addr) > >> +# define test_and_clear_bit_le(nr, addr) \ > >> + test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, addr) > >> +#else > >> +# define test_bit_le test_bit > >> +# define set_bit_le set_bit > >> +# define clear_bit_le clear_bit > >> +# define test_and_set_bit_le test_and_set_bit > >> +# define test_and_clear_bit_le test_and_clear_bit > >> +#endif > > > > nit: does the formatting above look right after applying the patch? > > It looked ok to me, but I can add some more tabs to even make it nicer :) > > >> @@ -293,6 +341,10 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations, > >> * case where the size is not aligned to 64 pages. > >> */ > >> guest_num_pages = (1ul << (30 - guest_page_shift)) + 16; > >> +#ifdef __s390x__ > >> + /* Round up to multiple of 1M (segment size) */ > >> + guest_num_pages = (guest_num_pages + 0xff) & ~0xffUL; > > > > We could maybe do this for all architectures as well. > > It's really only needed on s390x, so I think we should keep the #ifdef here. > OK Thanks, drew