From patchwork Wed Dec 22 15:18:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 428011 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBMFIsX6020357 for ; Wed, 22 Dec 2010 15:18:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686Ab0LVPSw (ORCPT ); Wed, 22 Dec 2010 10:18:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51731 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275Ab0LVPSv (ORCPT ); Wed, 22 Dec 2010 10:18:51 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBMFIpfD013298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 Dec 2010 10:18:51 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBMFIo6d005406; Wed, 22 Dec 2010 10:18:50 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id B58DF18D3E9; Wed, 22 Dec 2010 17:18:49 +0200 (IST) Date: Wed, 22 Dec 2010 17:18:49 +0200 From: Gleb Natapov To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] Add ability to drop pages through testdev Message-ID: <20101222151849.GF2231@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 22 Dec 2010 15:18:56 +0000 (UTC) diff --git a/hw/testdev.c b/hw/testdev.c index d1abf59..29df385 100644 --- a/hw/testdev.c +++ b/hw/testdev.c @@ -1,3 +1,4 @@ +#include #include "hw.h" #include "qdev.h" #include "isa.h" @@ -46,6 +47,16 @@ static uint32_t test_device_ioport_read(void *opaque, uint32_t addr) return test_device_ioport_data; } +static void test_device_flush_page(void *opaque, uint32_t addr, uint32_t data) +{ + target_phys_addr_t len = 4096; + void *a = cpu_physical_memory_map(data & ~0xffful, &len, 0); + + mprotect(a, 4096, PROT_NONE); + mprotect(a, 4096, PROT_READ|PROT_WRITE); + cpu_physical_memory_unmap(a, len, 0, 0); +} + static char *iomem_buf; static uint32_t test_iomem_readb(void *opaque, target_phys_addr_t addr) @@ -104,6 +115,7 @@ static int init_test_device(ISADevice *isa) register_ioport_write(0xe0, 1, 2, test_device_ioport_write, dev); register_ioport_read(0xe0, 1, 4, test_device_ioport_read, dev); register_ioport_write(0xe0, 1, 4, test_device_ioport_write, dev); + register_ioport_write(0xe4, 1, 4, test_device_flush_page, dev); register_ioport_write(0x2000, 24, 1, test_device_irq_line, NULL); iomem_buf = qemu_mallocz(0x10000); iomem = cpu_register_io_memory(test_iomem_read, test_iomem_write, NULL);