Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1721318pxy; Thu, 29 Apr 2021 13:02:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj2rMHBQp5XRJuN+ddACCptkWGDOcXUHEiFStxLb12TvckMrosT2rr7SrcuL9hmqLmZ6bt X-Received: by 2002:aa7:8890:0:b029:27d:90da:39e1 with SMTP id z16-20020aa788900000b029027d90da39e1mr1363186pfe.43.1619726528636; Thu, 29 Apr 2021 13:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619726528; cv=none; d=google.com; s=arc-20160816; b=c8gAi/cfBeC3ysXbbr8Bkrj9hXUUF4Hsl9crsa9su10hD9TeG+jpoAXzO0i4YPTCPS i833HUEWE+b9PnJr5ggILhxNy4kJK6YM5WIC5Z30p4qOOPrIh7WNZGkD8N7+K/26sRHs APPHVCN0QVsHfzD8Uz2H9r8+nJlx66rqCEiJN/ApZQIQ5N374lg8YfWlgseSz52FCF44 I2ijTDotOwE9Rdp+Tucq+63b4CITmixEtmSY6p193GcB35wBnhqWxt0H4vaynZAYs9yn UcX7vjoAewxTpLtJSeKimNk32SJ6DdL0rU+ErvP9yUxEl3MP/jUIuxlR9gvfp8IeIHrZ hjUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=+M4to1dcOs700isxx4oGCjHBz32mVchtGZDofF69pWA=; b=k/KZ1J7SB5Pv9z2n79OVRidKxS7+Iw7AXeulM1jVPLfe4xjbPsDgPdDr9QHfMzB3UX +smJqQ46Yf1hsmnCWaJ0dtOeT/IjeDjvk9ziTCOVaDkkEq3+gYMYcGZJhIDzmlUVP3n6 t7SYSqp+kCDpLZRRNmTXdVhYbuFlvRGUK9xQadn11vlzJdtLaopw6rtrAKPZCUAwhZeb IQtJ2tq+Nfz5jG+BBMAsqA7TpGLLAmQ8CASxEbOyIg5SoZqOwzPilyHF4CrjaNgMLl/I XM4ZgHi7UPSoeUJpL77oMe58pKv0thdNBO9I651voQKjksK0zrsJrx9Tg9gz/nC/MyPc 8jRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="SDbr2A/9"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si848850pli.143.2021.04.29.13.01.29; Thu, 29 Apr 2021 13:02:08 -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=@redhat.com header.s=mimecast20190719 header.b="SDbr2A/9"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234076AbhD2TsJ (ORCPT + 99 others); Thu, 29 Apr 2021 15:48:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60299 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233998AbhD2TsH (ORCPT ); Thu, 29 Apr 2021 15:48:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619725639; 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=+M4to1dcOs700isxx4oGCjHBz32mVchtGZDofF69pWA=; b=SDbr2A/9Wc1ywqXyg97vQQSHt5i2T9u9S2Pdo+18U6IJQkr9UGsFpWmTZ1u4dg99J1l42i eV3GqRqIc15Bm+/6TA49r1KcsMAln7/BzrNpVgbAdILTHG4/e6E6y9q4CLdIaGoaSHQGob 5v5C2VEsUPpDmAzF/UV5K+tK+7AStcc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-KamNEiW9NsGsTkhGWHaQ0w-1; Thu, 29 Apr 2021 15:47:02 -0400 X-MC-Unique: KamNEiW9NsGsTkhGWHaQ0w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E7048189C6; Thu, 29 Apr 2021 19:47:00 +0000 (UTC) Received: from redhat.com (ovpn-113-225.phx2.redhat.com [10.3.113.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2AFF69513; Thu, 29 Apr 2021 19:46:59 +0000 (UTC) Date: Thu, 29 Apr 2021 13:46:59 -0600 From: Alex Williamson To: Shanker R Donthineni Cc: Marc Zyngier , Will Deacon , "Catalin Marinas" , Christoffer Dall , , , , , Vikram Sethi , Jason Sequeira Subject: Re: [RFC 1/2] vfio/pci: keep the prefetchable attribute of a BAR region in VMA Message-ID: <20210429134659.321a5c3c@redhat.com> In-Reply-To: <470360a7-0242-9ae5-816f-13608f957bf6@nvidia.com> References: <20210429162906.32742-1-sdonthineni@nvidia.com> <20210429162906.32742-2-sdonthineni@nvidia.com> <20210429122840.4f98f78e@redhat.com> <470360a7-0242-9ae5-816f-13608f957bf6@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Apr 2021 14:14:50 -0500 Shanker R Donthineni wrote: > Thanks Alex for quick reply. >=20 > On 4/29/21 1:28 PM, Alex Williamson wrote: > > If this were a valid thing to do, it should be done for all > > architectures, not just ARM64. However, a prefetchable range only > > necessarily allows merged writes, which seems like a subset of the > > semantics implied by a WC attribute, therefore this doesn't seem > > universally valid. > > > > I'm also a bit confused by your problem statement that indicates that > > without WC you're seeing unaligned accesses, does this suggest that > > your driver is actually relying on WC semantics to perform merging to > > achieve alignment? That seems rather like a driver bug, I'd expect UC > > vs WC is largely a difference in performance, not a means to enforce > > proper driver access patterns. Per the PCI spec, the bridge itself can > > merge writes to prefetchable areas, presumably regardless of this > > processor attribute, perhaps that's the feature your driver is relying > > on that might be missing here. Thanks, =20 > The driver uses WC semantics, It's mapping PCI prefetchable BARS > using ioremap_wc().=C2=A0 We don't see any issue for x86 architecture, > driver works fine in the host and guest kernel. The same driver works > on ARM64 kernel but crashes inside VM. GPU driver uses the > architecture agnostic function ioremap_wc() like other drivers. This > limitation applies to all the drivers if they use WC memory and > follow ARM64 NORMAL-NC access rules. x86 KVM works for other reasons, KVM will trust the vCPU attributes for the memory range rather than relying only on the host mapping. > On ARM64, ioremap_wc() is mapped to non-cacheable memory-type, no > side effects on reads and unaligned accesses are allowed as per > ARM-ARM architecture. The driver behavior is different in host vs > guest on ARM64.=C2=A0 Per the PCI spec, prefetchable memory only necessarily allows the bridge to merge writes. I believe this is only a subset of what WC mappings allow, therefore I expect this is incompatible with drivers that do not use WC mappings. =20 > ARM CPU generating alignment faults before transaction reaches the > PCI-RC/switch/end-point-device. If an alignment fault is fixed by configuring a WC mapping, doesn't that suggest that the driver performed an unaligned access itself and is relying on write combining by the processor to correct that error? That's wrong. Fix the driver or please offer another explanation of how the WC mapping resolves this. I suspect you could enable tracing in QEMU, disable MMIO mmaps on the vfio-pci device and find the invalid access. > We've two concerns here: > =C2=A0=C2=A0 - Performance impacts for pass-through devices. > =C2=A0=C2=A0 - The definition of ioremap_wc() function doesn't match the = host > kernel on ARM64 Performance I can understand, but I think you're also using it to mask a driver bug which should be resolved first. Thanks, Alex