From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gLCFe-0000Wk-C3 for mharc-grub-devel@gnu.org; Fri, 09 Nov 2018 14:15:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLCFX-0000Wb-UR for grub-devel@gnu.org; Fri, 09 Nov 2018 14:15:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLCFL-000485-Ja for grub-devel@gnu.org; Fri, 09 Nov 2018 14:15:18 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40916) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gLCFK-000475-M2 for grub-devel@gnu.org; Fri, 09 Nov 2018 14:15:11 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA9JE96L035590; Fri, 9 Nov 2018 19:15:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2018-07-02; bh=nmhoO584hGBY/f4wEfqs17qVvcZZ6jIctoP3XzPl3kY=; b=oIyfbEqaReuQNuaUP1UrHy9fWXltwarnSDso/R0afIJ5uN/NgSmPNtFYJqMgnnJOYL6k 3/63OTJyr/LWqmIFp2srY9hpNOdI5RCxQzTF7vuq8V8NLkXP/68bPU86lIGdyr6yuQKB Cgwy434OsiogO2WtuwH6E1+b+65gWFyjhC8YVX3hTIZbqsMQYvkxZwWfBXQ3QY/rE1ua QKwnumqydLzotOS3AnvSxYOQaCdmUBxlUFIXiB0Vu5uGj2aoQ+AcRaVJnvYj+rWJQvtS 3GZQCOjgxUHlkcOL/pafhHOSppPZVwv/E941TSennWPo5dj49A8kJpUQyZbsiNLQyPfX aA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2nh33ugt8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Nov 2018 19:15:08 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA9JF2C4019679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Nov 2018 19:15:02 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA9JF1Ps011284; Fri, 9 Nov 2018 19:15:01 GMT Received: from olila.i.net-space.pl (/10.175.209.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 09 Nov 2018 11:15:01 -0800 Date: Fri, 9 Nov 2018 20:14:57 +0100 From: Daniel Kiper To: Juergen Gross Cc: grub-devel@gnu.org, xen-devel@lists.xen.org, phcoder@gmail.com, hans@knorrie.org Subject: Re: [PATCH v4 12/19] xen: add PCI MMIO areas to memory map Message-ID: <20181109191457.GF4363@olila.i.net-space.pl> References: <20181102123738.16395-1-jgross@suse.com> <20181102123738.16395-13-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20181102123738.16395-13-jgross@suse.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9072 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811090174 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2130.oracle.com id wA9JE96L035590 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Nov 2018 19:15:28 -0000 On Fri, Nov 02, 2018 at 01:37:31PM +0100, Juergen Gross wrote: > Add possible PCI space MMIO areas as "Reserved" to the memory map in > order to avoid using those areas for special Xen pages later. > > Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper but I would like to here something from Roger here too. Daniel > --- > V4: new patch (Roger Pau Monn=E9) > --- > grub-core/kern/i386/xen/pvh.c | 70 +++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 70 insertions(+) > > diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pv= h.c > index 58e6fefd5..442351d1d 100644 > --- a/grub-core/kern/i386/xen/pvh.c > +++ b/grub-core/kern/i386/xen/pvh.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -170,6 +171,73 @@ grub_xen_sort_mmap (void) > } > } > > +static grub_uint64_t > +grub_xen_pci_read (grub_pci_address_t addr, grub_uint32_t is_64bit) > +{ > + grub_uint64_t val; > + > + val =3D grub_pci_read (addr); > + if (is_64bit) > + { > + addr +=3D sizeof (grub_uint32_t); > + val |=3D ((grub_uint64_t) grub_pci_read (addr)) << 32; > + } > + > + return val; > +} > + > +static void > +grub_xen_pci_write (grub_pci_address_t addr, grub_uint64_t val, > + grub_uint32_t is_64bit) > +{ > + grub_pci_write (addr, (grub_uint32_t) val); > + if (is_64bit) > + { > + addr +=3D sizeof (grub_uint32_t); > + grub_pci_write (addr, val >> 32); > + } > +} > + > +static int > +grub_xen_pci_mmap (grub_pci_device_t dev, > + grub_pci_id_t pciid __attribute__ ((unused)), > + void *data __attribute__ ((unused))) > +{ > + int reg; > + grub_pci_address_t addr; > + grub_uint32_t val; > + grub_uint64_t mmio_addr, mmio_size; > + > + if (nr_map_entries =3D=3D ARRAY_SIZE (map)) > + return 1; > + > + for (reg =3D GRUB_PCI_REG_ADDRESSES; reg < GRUB_PCI_REG_CIS_POINTER; > + reg +=3D sizeof (grub_uint32_t)) > + { > + addr =3D grub_pci_make_address (dev, reg); > + val =3D grub_pci_read (addr); > + if (val =3D=3D 0 || > + (val & GRUB_PCI_ADDR_SPACE_MASK) !=3D GRUB_PCI_ADDR_SPACE_MEMORY) > + continue; > + > + val &=3D GRUB_PCI_ADDR_MEM_TYPE_MASK; > + mmio_addr =3D grub_xen_pci_read (addr, val); > + grub_xen_pci_write (addr, ~0ULL, val); > + mmio_size =3D ~(grub_xen_pci_read (addr, val) & ~0x0fULL) + 1; > + grub_xen_pci_write (addr, mmio_addr, val); > + > + map[nr_map_entries].type =3D GRUB_MEMORY_RESERVED; > + map[nr_map_entries].addr =3D mmio_addr; > + map[nr_map_entries].len =3D mmio_size; > + nr_map_entries++; > + > + if (val) > + reg +=3D sizeof (grub_uint32_t); > + } > + > + return 0; > +} > + > static void > grub_xen_get_mmap (void) > { > @@ -182,6 +250,8 @@ grub_xen_get_mmap (void) > grub_xen_panic ("Could not get memory map from Xen.\n"); > nr_map_entries =3D memmap.nr_entries; > > + grub_pci_iterate (grub_xen_pci_mmap, NULL); > + > grub_xen_sort_mmap (); > } > > -- > 2.16.4