From patchwork Sun May 29 22:37:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 9140005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CAE96607DA for ; Sun, 29 May 2016 22:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE5E328188 for ; Sun, 29 May 2016 22:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B34CB281FF; Sun, 29 May 2016 22:40:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 56DB428188 for ; Sun, 29 May 2016 22:40:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b79LR-0004A9-Ka; Sun, 29 May 2016 22:38:05 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b79LQ-00048Z-SY for xen-devel@lists.xenproject.org; Sun, 29 May 2016 22:38:04 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id C3/62-30266-C4F6B475; Sun, 29 May 2016 22:38:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOIsWRWlGSWpSXmKPExsVyMfSas653vne 4wZ/V0hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aLnbdYC5rlK45+/MbawLhVpIuRk0NIYAaj xMYTpl2MXBwSAv2sEovbtzGBJCQEYiTO/G1hg7DLJK58f84C0aAhcftmIztIg5DARCaJ1w/+s YMk2AS0Jdpe72IFsUUElCTurZoMNohZoFjixfmTYIOEBZwlrh6+AVTPwcEioCrx5qsPSJgXKD yjaxEzxC45icvTH4CVcwq4SLzZPJ0ZYq+zxLvFJ9knMPIvYGRYxahenFpUllqka6iXVJSZnlG Sm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iREYPAxAsINx53OnQ4ySHExKorxuHN7hQnxJ+SmV GYnFGfFFpTmpxYcYZTg4lCR4TfKAcoJFqempFWmZOcAwhklLcPAoifD6gaR5iwsSc4sz0yFSp xiNObb8vraWiWPb1HtrmYRY8vLzUqXEeQ/mApUKgJRmlObBDYLF1yVGWSlhXkag04R4ClKLcj NLUOVfMYpzMCoJ80aDLOTJzCuB2/cK6BQmoFPMznmBnFKSiJCSamC0iWE0PbN2+ZatySxaU8Q lu48sWn3TxSRda9Nl5YmbnB5qJ8XYsF1+bfz30EnvLR039m5T3VKtpRbMG5K52SnSPnr953s1 b1ZqNShkXHjEO7/5omJ1X0jddROG9je76gVcTpjpmPv22wQ/VJHy1W9Jrr7jIMPHrzX3HAPP9 09/Ji5Pn8P1LVaJpTgj0VCLuag4EQAUtzHZqgIAAA== X-Env-Sender: tamas.k.lengyel@gmail.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1464561482!16542819!1 X-Originating-IP: [209.85.214.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16251 invoked from network); 29 May 2016 22:38:03 -0000 Received: from mail-it0-f67.google.com (HELO mail-it0-f67.google.com) (209.85.214.67) by server-13.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 May 2016 22:38:03 -0000 Received: by mail-it0-f67.google.com with SMTP id i127so2668767ita.3 for ; Sun, 29 May 2016 15:38:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u5xK6km9aUdlmq2E0VA58ZoWmnkBjiW75Jt3YbhvsYA=; b=Dh2XxSHk6hfNowCnp++ncARoIxvwBm+IdBZ2ypRjM8a99xRDJbUqm5qbWoqXHTgm97 PW0VnOGx4VQCt7GZ2e6DGA92hd9cDxQbvSNZ+1mZRhR3Y47LjAIHPVeRFfvNm2SWYwf/ df8Xi4jqXB7nSeJIP0rX1Pe6mbAF1Mg/jsSFjxz6LUq2e4y2k8a5oTV9EOfoNwOhkATi jdn7YYjEzivKPpV6toEcUNGQqHTbkSp6xiY9IKfI6O7Y4DU14sxnjlLPgvq7Gc9w84WB dHwCv8BvvPYteDThmMPIqT1zOwpr923sTXo7vbqw0WvxO8Ywo+5IbbH8OKauqO99oiRy XzuA== X-Gm-Message-State: ALyK8tKBPCIWnOTYHm13ZfWq1sD/0fAZdnMnbMBaU0VajCSsCAVqasnGdkkAWeyVjDZ5rw== X-Received: by 10.36.29.13 with SMTP id 13mr5209931itj.99.1464561482078; Sun, 29 May 2016 15:38:02 -0700 (PDT) Received: from l1.lan (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id xo3sm6222165igc.22.2016.05.29.15.38.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 May 2016 15:38:01 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Sun, 29 May 2016 16:37:09 -0600 Message-Id: <1464561430-13465-7-git-send-email-tamas@tklengyel.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464561430-13465-1-git-send-email-tamas@tklengyel.com> References: <1464561430-13465-1-git-send-email-tamas@tklengyel.com> Cc: Wei Liu , Tamas K Lengyel , Ian Jackson Subject: [Xen-devel] [PATCH v4 7/8] tools/xen-access: add test-case for ARM SMC 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tamas K Lengyel Acked-by: Razvan Cojocaru Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu --- tools/tests/xen-access/xen-access.c | 48 ++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index f26e723..1b2b3fd 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -1,5 +1,4 @@ -/* - * xen-access.c +/* xen-access.c * * Exercises the basic per-page access mechanisms * @@ -334,6 +333,8 @@ void usage(char* progname) fprintf(stderr, "Usage: %s [-m] write|exec", progname); #if defined(__i386__) || defined(__x86_64__) fprintf(stderr, "|breakpoint|altp2m_write|altp2m_exec"); +#elif defined(__arm__) || defined(__aarch64__) + fprintf(stderr, "|privcall"); #endif fprintf(stderr, "\n" @@ -357,6 +358,7 @@ int main(int argc, char *argv[]) int required = 0; int breakpoint = 0; int shutting_down = 0; + int privcall = 0; int altp2m = 0; uint16_t altp2m_view_id = 0; @@ -412,6 +414,11 @@ int main(int argc, char *argv[]) default_access = XENMEM_access_rw; altp2m = 1; } +#elif defined(__arm__) || defined(__aarch64__) + else if ( !strcmp(argv[0], "privcall") ) + { + privcall = 1; + } #endif else { @@ -524,6 +531,16 @@ int main(int argc, char *argv[]) } } + if ( privcall ) + { + rc = xc_monitor_privileged_call(xch, domain_id, 1); + if ( rc < 0 ) + { + ERROR("Error %d setting privileged call trapping with vm_event\n", rc); + goto exit; + } + } + /* Wait for access */ for (;;) { @@ -535,6 +552,9 @@ int main(int argc, char *argv[]) if ( breakpoint ) rc = xc_monitor_software_breakpoint(xch, domain_id, 0); + if ( privcall ) + rc = xc_monitor_privileged_call(xch, domain_id, 0); + if ( altp2m ) { rc = xc_altp2m_switch_to_view( xch, domain_id, 0 ); @@ -635,7 +655,7 @@ int main(int argc, char *argv[]) rsp.u.mem_access = req.u.mem_access; break; case VM_EVENT_REASON_SOFTWARE_BREAKPOINT: - printf("Breakpoint: rip=%016"PRIx64", gfn=%"PRIx64" (vcpu %d)\n", + printf("Breakpoint: rip=%016"PRIx64" gfn=%"PRIx64" (vcpu %d)\n", req.data.regs.x86.rip, req.u.software_breakpoint.gfn, req.vcpu_id); @@ -650,7 +670,29 @@ int main(int argc, char *argv[]) interrupted = -1; continue; } + break; + case VM_EVENT_REASON_PRIVILEGED_CALL: + { + const struct vm_event_regs_arm *in_regs = &req.data.regs.arm; + struct vm_event_regs_arm *out_regs = &rsp.data.regs.arm; + bool is32bit = !!(in_regs->cpsr & PSR_MODE_BIT); + uint64_t pc; + + *out_regs = *in_regs; + + if ( is32bit ) { + pc = in_regs->arch.arm32.pc; + out_regs->arch.arm32.pc += 4; + } else { + pc = in_regs->arch.arm64.pc; + out_regs->arch.arm64.pc += 8; + } + printf("Privileged call: pc=%016"PRIx64" (vcpu %d)\n", + pc, req.vcpu_id); + + rsp.flags |= VM_EVENT_FLAG_SET_REGISTERS; + } break; case VM_EVENT_REASON_SINGLESTEP: printf("Singlestep: rip=%016"PRIx64", vcpu %d, altp2m %u\n",