From: Stefan Berger Subject: [PATCH] let set_phys_to_machine return the old entry Date: Thu, 20 Apr 2006 14:34:13 -0400 Message-ID: <1145558053.10850.6.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-5+w7CWeSIDejTqlstI2W" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-5+w7CWeSIDejTqlstI2W Content-Type: text/plain Content-Transfer-Encoding: 7bit The attached patch makes set_phys_to_machine(pfn,mfn) return the old entry in the array, such that the old entry can be restored again using the same call. If the feature XENFEAT_auto_translate_physmap is not enabled, then these two calls will end up in no-op relative to changes to the phys_to_machine_mapping array. There's currently only one occurrence where remembering the entry from the array is necessary and this is in the vTPM backend driver. This patch builds on top of the previously posted TPM backend patch. Signed-off-by: Stefan Berger --=-5+w7CWeSIDejTqlstI2W Content-Disposition: attachment; filename=set_phys_to_machine.diff Content-Type: text/x-patch; name=set_phys_to_machine.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c @@ -297,9 +297,8 @@ int _packet_write(struct packet *pak, pfn = __pa(MMAP_VADDR(tpmif, i)) >> PAGE_SHIFT; mfn = FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT); - mfn_orig = phys_to_machine_mapping[pfn]; - set_phys_to_machine(pfn, mfn); + mfn_orig = set_phys_to_machine(pfn, mfn); tocopy = MIN(size - offset, PAGE_SIZE); Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h @@ -137,13 +137,17 @@ static inline unsigned long mfn_to_local return pfn; } -static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) +static inline +unsigned long set_phys_to_machine(unsigned long pfn, unsigned long mfn) { + unsigned long mfn_orig; if (xen_feature(XENFEAT_auto_translated_physmap)) { BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); - return; + return phys_to_machine_mapping[pfn]; } + mfn_orig = phys_to_machine_mapping[pfn]; phys_to_machine_mapping[pfn] = mfn; + return mfn_orig; } /* Definitions for machine and pseudophysical addresses. */ --=-5+w7CWeSIDejTqlstI2W Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-5+w7CWeSIDejTqlstI2W--