From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHSFx-00015W-DS for qemu-devel@nongnu.org; Tue, 21 Jul 2015 03:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHSFs-0004fd-AY for qemu-devel@nongnu.org; Tue, 21 Jul 2015 03:46:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHSFs-0004fT-5a for qemu-devel@nongnu.org; Tue, 21 Jul 2015 03:46:24 -0400 References: <1437389593-15297-1-git-send-email-real@ispras.ru> From: Paolo Bonzini Message-ID: <55ADF8CB.8050500@redhat.com> Date: Tue, 21 Jul 2015 09:46:19 +0200 MIME-Version: 1.0 In-Reply-To: <1437389593-15297-1-git-send-email-real@ispras.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] PAM: make PAM emulation closer to documentation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Efimov Vasily , qemu-devel@nongnu.org Cc: Kirill Batuzov , "Michael S. Tsirkin" On 20/07/2015 12:53, Efimov Vasily wrote: > This patch improves PAM emulation. > > PAM defines 4 memory access redirection modes. In mode 1 reads are directed to > RAM and writes are directed to PCI. In mode 2 it is contrary. In mode 0 all > access is directed to PCI. In mode 3 it is directed to RAM. Currently all modes > are emulated using aliases. It is good for modes 0 and 3 but modes 1 and 2 > require more complicated logic. Present API has not needed region type. > > The patch uses ROM-like regions for modes 1 and 2. Each region has I/O callbacks > to redirect access to destination defined by current mode. Write access is > always redirected by callback. If actual read source is RAM or ROM (it is > common case) then ram_addr of PAM region is set to ram_addr of source region > with offset. Otherwise, when source region is an I/O region, reading is > redirected to source region read callback by PAM region one. > > The reasons of ram_addr modification for read redirection are: > - QEMU cannot execute code outside RAM or ROM (while BIOS tries exactly that); > - it is faster because of TLB is used. > > Redirection is based on address spaces: for PCI and for RAM. QEMU has no ones so > PAM creates private address spaces with root regions that alias to actual PCI > and RAM regions. > > The memory commit callbacks are used to keep read source and write destination > address spaces and ram_addr up to date. > > Signed-off-by: Efimov Vasily Out of curiosity, would it be necessary to flush the TLB when the PAM registers change? In QEMU, the TLB also has the function of a cache in some sense (because, by pointing to a ram_addr_t, it prevents reads, writes or fetches from going through the slow MMIO path). Paolo