From owner-svn-src-all@FreeBSD.ORG Sat Oct 25 09:00:09 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 332C9F2; Sat, 25 Oct 2014 09:00:09 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA69C8F1; Sat, 25 Oct 2014 09:00:08 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s9P902jw031429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 25 Oct 2014 12:00:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s9P902jw031429 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s9P900hQ031428; Sat, 25 Oct 2014 12:00:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 25 Oct 2014 12:00:00 +0300 From: Konstantin Belousov To: Rui Paulo Subject: Re: svn commit: r273598 - in head: include sys/dev/acpica Message-ID: <20141025090000.GG1877@kib.kiev.ua> References: <33decfcd-e77c-4e4c-8161-9f4a232213c6@me.com> <20141024194546.GE1877@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20141024194546.GE1877@kib.kiev.ua> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Rui Paulo X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Oct 2014 09:00:09 -0000 On Fri, Oct 24, 2014 at 10:45:46PM +0300, Konstantin Belousov wrote: > On Fri, Oct 24, 2014 at 07:33:07PM +0000, Rui Paulo wrote: > > On Oct 24, 2014, at 12:20 PM, Konstantin Belousov wrote: > > > > > +static int > > > +hpet_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, > > > + int nprot, vm_memattr_t *memattr) > > > +{ > > > + š šstruct hpet_softc *sc; > > > + > > > + š šsc = cdev->si_drv1; > > > + š š š šif (offset > rman_get_size(sc->mem_res)) > > > + š š š š š š š šreturn (EINVAL); > > > + š šif (!sc->mmap_allow_write && (nprot & PROT_WRITE)) > > > + š š šreturn (EPERM); > > > + š š š*paddr = rman_get_start(sc->mem_res) + offset; > > What is the memattr for the backing page ? Is it set to non-cached > > mode somehow ? I was not able to find place where would this happen. > > š > > I expect it to be set to non-cached since it's a device anyway, but I don't know where it is. šDuring my testing, I did not see any problems with cached values, though. > > > I am not claiming that it is wrong, only that I do not see an easy reason > why it is right. Just printing the *memattr would provide the confidence. > Ok, I did looked at the pte of the HPET page. I get the value 0x80000000fed00025 which coincides with the resource address 0xfed00000 reported by devinfo -vr for hpet (to double-check my findings). The low bits indicate that PAT0 pat entry is used for the page caching mode. Corresponding PAT MSR 0x277 has the following value: sandy% sudo cpucontrol -m 0x277 /dev/cpuctl0 MSR 0x277: 0x00010506 0x00070406 i.e. memory type is 6, which is write-back, according to SDM. This is wrong, as I feared. The patch below fixes the issue. The pte for HPET page is equal to 0x80000000fed0003d after the patch is applied, PAT3 is used, and its value is 0 == UNCACHEABLE, as it must be. Do you agree with the patch ? diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index 6b35f5c..0da8bae 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -356,6 +356,7 @@ hpet_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, if (!sc->mmap_allow_write && (nprot & PROT_WRITE)) return (EPERM); *paddr = rman_get_start(sc->mem_res) + offset; + *memattr = VM_MEMATTR_UNCACHEABLE; return (0); }