From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: Re: [PATCH kvm-unit-tests 01/17] x86: intel-iommu: add vt-d init test Date: Tue, 8 Nov 2016 12:42:31 -0500 Message-ID: <20161108174231.GI2793@pxdev.xzpeter.org> References: <1477468040-21034-1-git-send-email-peterx@redhat.com> <1477468040-21034-2-git-send-email-peterx@redhat.com> <20161108105234.GG10472@agordeev.lab.eng.brq.redhat.com> <20161108152418.GD2793@pxdev.xzpeter.org> <20161108174034.GB10352@agordeev.lab.eng.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: kvm@vger.kernel.org, drjones@redhat.com, rkrcmar@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: Alexander Gordeev Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34448 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751243AbcKHRme (ORCPT ); Tue, 8 Nov 2016 12:42:34 -0500 Content-Disposition: inline In-Reply-To: <20161108174034.GB10352@agordeev.lab.eng.brq.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Nov 08, 2016 at 06:40:35PM +0100, Alexander Gordeev wrote: [...] > > Looks like Linux is using memory barrior and volatile keywords to do > > the protection (build_mmio_read() for x86). I think at least I can add > > volatile here for each read/write to make it safer. Do you think > > that'll suffice here? E.g.: > > > > static inline uint64_t vtd_readq(unsigned int reg) > > { > > return *(volatile uint64_t *)(Q35_HOST_BRIDGE_IOMMU_ADDR + reg); > > } > > Yeah, I think with volatile it is better. But I am still missing > why not just use read/write which already exist and use volatile: > > static inline u64 __raw_readq(const volatile void *addr) > { > assert(sizeof(unsigned long) == sizeof(u64)); > return *(const volatile u64 *)addr; > } That's nice! I'll use it. Thanks, -- peterx