From patchwork Tue Jul 17 14:45:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 1205461 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6B7673FC8E for ; Tue, 17 Jul 2012 14:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754773Ab2GQOpQ (ORCPT ); Tue, 17 Jul 2012 10:45:16 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:54651 "EHLO e28smtp01.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750833Ab2GQOpO (ORCPT ); Tue, 17 Jul 2012 10:45:14 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Jul 2012 20:15:12 +0530 Received: from d28relay02.in.ibm.com (9.184.220.59) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Jul 2012 20:15:10 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6HEjAbF41877660; Tue, 17 Jul 2012 20:15:10 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6HKESKb030507; Wed, 18 Jul 2012 06:14:29 +1000 Received: from localhost.localdomain ([9.123.236.99]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6HKERbp030470; Wed, 18 Jul 2012 06:14:27 +1000 Message-ID: <50057A73.40005@linux.vnet.ibm.com> Date: Tue, 17 Jul 2012 22:45:07 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Xiao Guangrong CC: Avi Kivity , Marcelo Tosatti , LKML , KVM Subject: [PATCH 08/10] KVM: introduce readonly_bad_hva References: <5005791B.8040807@linux.vnet.ibm.com> In-Reply-To: <5005791B.8040807@linux.vnet.ibm.com> x-cbid: 12071714-4790-0000-0000-000003BABE6A Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In the later patch, it indicates failure when we try to get a writable hva from the readonly slot Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index b70f1a4..c056736 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -994,9 +994,19 @@ static inline unsigned long bad_hva(void) return PAGE_OFFSET; } +static inline unsigned long readonly_bad_hva(void) +{ + return PAGE_OFFSET + PAGE_SIZE; +} + +static int kvm_is_readonly_bad_hva(unsigned long addr) +{ + return addr == readonly_bad_hva(); +} + int kvm_is_error_hva(unsigned long addr) { - return addr == bad_hva(); + return addr == bad_hva() || kvm_is_readonly_bad_hva(addr); } EXPORT_SYMBOL_GPL(kvm_is_error_hva);