From patchwork Mon Mar 14 17:55:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 8582571 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D9889F54C for ; Mon, 14 Mar 2016 17:58:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8388A20145 for ; Mon, 14 Mar 2016 17:58:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB7EF200FE for ; Mon, 14 Mar 2016 17:58:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1afWj4-00050n-Cg; Mon, 14 Mar 2016 17:56:18 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1afWj3-0004y0-49 for xen-devel@lists.xen.org; Mon, 14 Mar 2016 17:56:17 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id BA/BC-29419-04BF6E65; Mon, 14 Mar 2016 17:56:16 +0000 X-Env-Sender: prvs=874c279eb=anthony.perard@citrix.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1457978168!28652985!5 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36360 invoked from network); 14 Mar 2016 17:56:15 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 14 Mar 2016 17:56:15 -0000 X-IronPort-AV: E=Sophos;i="5.24,336,1454976000"; d="scan'208";a="345467651" From: Anthony PERARD To: Date: Mon, 14 Mar 2016 17:55:44 +0000 Message-ID: <1457978150-27201-10-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1457978150-27201-1-git-send-email-anthony.perard@citrix.com> References: <1457978150-27201-1-git-send-email-anthony.perard@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Keir Fraser , Stefano Stabellini , Andrew Cooper , Ian Jackson , Jan Beulich , Anthony PERARD , Wei Liu Subject: [Xen-devel] [PATCH v4 09/14] hvmloader: Check modules whereabouts in perform_tests X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As perform_tests() is going to clear memory past 4MB, we check that the memory can be use or we skip the tests. Signed-off-by: Anthony PERARD --- Changes in v4: - move the check into the perform_test() function. - skip tests instead of using BUG. New in V3 --- tools/firmware/hvmloader/tests.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/firmware/hvmloader/tests.c b/tools/firmware/hvmloader/tests.c index fea3ad3..7996206 100644 --- a/tools/firmware/hvmloader/tests.c +++ b/tools/firmware/hvmloader/tests.c @@ -210,6 +210,26 @@ void perform_tests(void) return; } + /* Check that tests does not use memory where modules are stored */ + if ( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) > 4 << 20 + && (uint32_t)hvm_start_info < 8 << 20 ) + { + printf("Skipping tests due to memory used by hvm_start_info\n"); + return; + } + for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ ) + { + const struct hvm_modlist_entry *modlist = + (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr; + if ( modlist[i].paddr + && modlist[i].paddr + modlist[i].size > 4ul << 20 + && modlist[i].paddr < 8ul << 20 ) + { + printf("Skipping tests due to memory used by a module\n"); + return; + } + } + passed = skipped = 0; for ( i = 0; tests[i].test; i++ ) {