Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2305445pxb; Fri, 17 Sep 2021 06:59:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqYfzokU1d/yhycgUAesQyDoaYY8pWEsRAA/hm/BZbNT+iXM+j2W+C9JgyCdgRnYWlK9A0 X-Received: by 2002:a17:906:2ed1:: with SMTP id s17mr12749348eji.261.1631887134207; Fri, 17 Sep 2021 06:58:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631887133; cv=pass; d=google.com; s=arc-20160816; b=cQlqlwVmE0JAzCvTPbCrkvqH82rVRrOyKAGM2TnvQ07OwUv53EUeU+NPj8C35lsE56 qq3JOpaBVq0kAQ3rmA0TrnGGn6zEI5p5IVJe/bVTgINUxUgN4ehwOYNTBDd+kcs6vxJb cKgoYT7jJhCqOHc4oigDrJI/5/nKVVwhx2WajksLAuoXn5w6gQRq+qeCETBZDl/meZdX TECm+D34mhO6grk/m+aqvD2KbIIepK0nRaRpdWvP/PqpeCBnsRj0WGne18JuIeH4PZEs 828o+UBb7ibHRcxcrzwKTeOrnV94qmS2kS9BtB/YiVS/Vn0jY18orH/TAdvUnuU2Ydle /Rdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:references :cc:to:from:subject:dkim-signature; bh=xygT969cDBZ/j2pA5jAQZPS3mU7sdWk4emBIUX/9lVE=; b=Se6AuwzrGMs19XrIhck/xx3dB0kg27V0LUqlYVo7N6qI9WFIyReOEe+6i4AEkjH2Uj PkggdJsKgcCnhVcHPQqsvcX+G5Hfr6cz/zpc6jK60iAS023cxb7/3a/epDs5T1jSZNKb 8RvMsGVP5plMKvCguU2kj70wxWi2giWCSXsHolMA6pXgqQMKcvqiZmbizK7BgMp8wWZ+ 92GoOBTKV1Eau5CpUYpiI2Sb5F30NMkWotiM2CkA4XfrFKNcxqZIIQg9A5QfkE72zSF6 Cx3O3gdAlbuEE4yIbUZuZGZ9nYSSfVy1QNdr4yfxSUzJIeGAQURVL+xrTRKqvJjl3EGB 3Y5A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=W9TAmaYN; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v30si6399537ejk.261.2021.09.17.06.58.30; Fri, 17 Sep 2021 06:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=W9TAmaYN; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238908AbhIQKrT (ORCPT + 99 others); Fri, 17 Sep 2021 06:47:19 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.111.102]:29492 "EHLO de-smtp-delivery-102.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbhIQKrS (ORCPT ); Fri, 17 Sep 2021 06:47:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1631875555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xygT969cDBZ/j2pA5jAQZPS3mU7sdWk4emBIUX/9lVE=; b=W9TAmaYNRJX6PYHTNKiCWHjq0BNDf8SV3TKCRCC5PYoinxmk2e3IUZOgaRRU0k8dRZ1fYI Wy7d/uPBxu1US9dBO9scyjvHwVAnpMifEq/xnqM6itJwwWyeg1ohLQE/nz6LlIzPDnwfiz J3EjnL50pBwNKnhHqPlwvPWmjVGqjAE= Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2109.outbound.protection.outlook.com [104.47.18.109]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-28-GrDtbzgpNkWMdQW2zCUVqg-1; Fri, 17 Sep 2021 12:45:54 +0200 X-MC-Unique: GrDtbzgpNkWMdQW2zCUVqg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QipcfJjC3Xsc6Dmx/BuF/G9EHVfVtUX1uqsYY8SDfToaGCDxpA+2TmZPbBhITA6nHnVHJ0l21rS0x8aBxdOBbnjkNDRDsxNVKNhxx7J4zNT13fY2A+/4sdTb3NycPl77+nW6vC+EVBDYQEvZ6f154TyZnr2zizkCOrlwjId6oA/pUeLqRFBsLFdU57DAf1dDOrcKaBhOXkJskTDB+LuCONqvq0EYecKduk3pn/1cvOHdL/LS7R+DDLgYhWpSz55dj8V0LWCMJT8wLcp08N9IggF14TtNqbb56mVz+ufn/PmBc9d7THdv+K4CLzmiLZ2nyEtTA37RmfQWHvyuQrpT2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xygT969cDBZ/j2pA5jAQZPS3mU7sdWk4emBIUX/9lVE=; b=H1GMQi1hiWB9rb6AhRrlSKlWcuoeaNGgzGBuZYAqHnGuSrUz5GLZlU+kIdLT5t54O1a9LRYRAoFF2prEy2yqmnWhmnh7cB9NSTPzdmrzQqSviyFyMMYcF35DJVslYFfyIOZzMUQwZBClVljmx6qObMnesHdp9Nxaofp4bL9/ZJBNe7GFoRHSh7pthHFls6Rah1ZyPfnExcnfp2WIv5taFJlwnjhxWZ7RwYP8CR8BzflpJ8PFb2KiBFscCPFuqg+XVWnskRIKoJeAeuC1L5lqHmx3bOqjhyXtVSs6ZWLNx78yXohowi0mJNnKS4mrQODRX2X2j7roI8HMjE46Opbx0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: lists.linux-foundation.org; dkim=none (message not signed) header.d=none;lists.linux-foundation.org; dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB7038.eurprd04.prod.outlook.com (2603:10a6:800:12d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Fri, 17 Sep 2021 10:45:52 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::4d37:ec64:4e90:b16b%7]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 10:45:52 +0000 Subject: [PATCH v2 1/4] swiotlb-xen: ensure to issue well-formed XENMEM_exchange requests From: Jan Beulich To: Juergen Gross , Boris Ostrovsky Cc: Stefano Stabellini , lkml , "xen-devel@lists.xenproject.org" , "hch@lst.de" , Konrad Wilk , "iommu@lists.linux-foundation.org" References: <164e58ff-2edd-2c99-ac3d-e18eb06ff731@suse.com> Message-ID: <7b3998e3-1233-4e5a-89ec-d740e77eb166@suse.com> Date: Fri, 17 Sep 2021 12:45:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <164e58ff-2edd-2c99-ac3d-e18eb06ff731@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PR3P189CA0085.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::30) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.156.60.236] (37.24.206.209) by PR3P189CA0085.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Fri, 17 Sep 2021 10:45:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51a8b658-b3cb-4ac7-1729-08d979c8519b X-MS-TrafficTypeDiagnostic: VI1PR04MB7038: X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jJvfl4TOCMxZk5Hkw6X1UGtuuJekKSpg5sbARmQDJzbR4PwzObuEuRLB4ElgjWxJ4DozlfkadWHD37Y3J/e9Fy86fiIg0OS/iWfK2TcROwvraU1+z69n8vFDvx9yzQ3DYLlwnF9Q5eIr0tMWUJ8Njc0xR+mXmdbdhauFYRziA9WjaY+LuldbvUY6HrMJX0Nb0ZBYtwLv3XtX34tBqlZk6YjVTjlgR5boCKsL06fnI0MKVnNdsV4RuV6B5dmqlHC7RoUo/9gSFu6+VuNgPweWUYooq8ABV53bwlXHVK4mBG6ghApj17HTUihckeXoOTwQZDrPgKE26eAikPz8/T+iCmCQ9NMGzU0OAdGRZBa7/9VoqowHDX7gEHT8TlSiu5JphBiuMeT1f8Uvc0841/9OVTLPWlMOwXhSlab7mdkMFk6S/29MvxEKSCJcNcuMECJLNJb93r44NzT7hf3sfBGLqAGMPZ2VpT7d13Rsc7BSpkZh47TtnLqyqejmZKtbKtCLGSZjqmN557F4nM24XgB6BKdZp6tSfhxL4fMKm/C15vYCTu75zp3gZcB3H6dOWT76KaIQ1R4lhlvlv6m4ZCoPAsbcu0yjVOV2OWYRN3UIATu2NHcDddDyz3zvHd5Tzcr41ZdZwEIKbbLRVNWjmJEFIZ3OFMC2AGFbpwBgKPRYiDl7bMq9WzZjFiS0LIv5Z59YeXX0NL9F2vBAkUVLHcYLwY20uDlEHR6JCBLUfdReuFg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(396003)(376002)(39860400002)(346002)(366004)(26005)(38100700002)(83380400001)(8676002)(36756003)(2616005)(66476007)(66556008)(6486002)(8936002)(2906002)(86362001)(186003)(31686004)(66946007)(956004)(5660300002)(316002)(4326008)(54906003)(110136005)(478600001)(31696002)(16576012)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Nzh0eE1QbWhKemFEN1F3N0V0anEwT0Q0TTNSb1BLZlRjOVA2cEtjQ1gwRVJT?= =?utf-8?B?eTVEQitvRzlKOUlXd2Q1MTVQK2tRSzQxZnVJZm1qOXFyNmlQVENrSVVTWW0v?= =?utf-8?B?Y2NRb1o0V29vY2c0elJlVGE4NjNFQ0ZnQkVpQlRVb2dScHJ5Sm11dlBBalQ5?= =?utf-8?B?L0ZsaDV1YWpDMG9kTnl4RUFJS2tsTldtUlo3TFNZSW10d013Y3Jt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jBOWENrMVBubmhxcVVB?= =?utf-8?B?Zy9PMG1Uc1VtZVViUHRBQU9GV1FGK003QlZPVnhkTTQ0aG1qRVVORkdJb21X?= =?utf-8?B?UVRGTEIzOWFMNENUZ0FVaEFBc3lPV2N1bnBzY3Z5eVR1THV4NVBFcVV0ZE5M?= =?utf-8?B?dzY3MFQ3R25WVlV5K1A4QTRBWTBRMk5ZcE1hRng4R2dMUFZBMDBSdE9RRjBu?= =?utf-8?B?VWZxMWtSaG9pU3Z2OVhDV3ZGWjMzTXNzakVQVElJb1lEa3hHK0Q5aWxBRjNo?= =?utf-8?B?SkdNNzh5R3hlQ3pqeHBIRlgrWVkvOWl6cnNSdWhWSGhUT2w4SmE5amlzNERv?= =?utf-8?B?d2F3K1p0dFVOYk9hbDFGbTlPSSs1YVV6b3lrT242cm5XK3ptVERMeDR3djFD?= =?utf-8?B?aWoybDRNR0FtM1lJZ2xGK2NOZmVMZHRieGVIbDcrYUNBVE1zQnVKYjFheDla?= =?utf-8?B?Ykp6ckhXZnpOMUlmcWVuOWtLVWVGVjZIM0JzMTVYeGxxWXUxNVp2Qmhmajlm?= =?utf-8?B?eUNCamdqSWd2WUhJeVl5ZkpJQUtRaERtdnhHeWFPUFJyeW02MXo1YnpkV0xZ?= =?utf-8?B?SThhSlhCQTBpdHprZTJFbGUrK3FiS1ZoNFBiUUdySjU4RTZnNHZnZERqck5M?= =?utf-8?Q?9BNYdZqpM/QexeFOt3WvwlNcoxKVn3MxN/rO72D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51a8b658-b3cb-4ac7-1729-08d979c8519b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 10:45:51.9854 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gg4diNqLAQ1fx64FdDFPcPfx1T/o/UzWchvG1YWd1pA9kTjucQnGvrZeUel1lzk+QfIzb/1NrKAowws/Hhq85A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7038 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the hypervisor hasn't been enforcing this, we would still better avoid issuing requests with GFNs not aligned to the requested order. Instead of altering the value also in the call to panic(), drop it there for being static and hence easy to determine without being part of the panic message. Signed-off-by: Jan Beulich --- I question how useful it is to wrap "bytes" in PAGE_ALIGN(), when it is a multiple of a segment's size anyway (or at least was supposed to be, prior to "swiotlb-xen: maintain slab count properly"). But that's perhaps yet another separate patch. --- v2: Drop logging of alignment. Wrap lines. --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -230,10 +230,11 @@ retry: /* * Get IO TLB memory from any location. */ - start = memblock_alloc(PAGE_ALIGN(bytes), PAGE_SIZE); + start = memblock_alloc(PAGE_ALIGN(bytes), + IO_TLB_SEGSIZE << IO_TLB_SHIFT); if (!start) - panic("%s: Failed to allocate %lu bytes align=0x%lx\n", - __func__, PAGE_ALIGN(bytes), PAGE_SIZE); + panic("%s: Failed to allocate %lu bytes\n", + __func__, PAGE_ALIGN(bytes)); /* * And replace that memory with pages under 4GB.