From patchwork Tue May 8 20:07:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Clark X-Patchwork-Id: 10387473 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 BA9156037F for ; Tue, 8 May 2018 20:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8C8128924 for ; Tue, 8 May 2018 20:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD19428E86; Tue, 8 May 2018 20:11:46 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D2EC28924 for ; Tue, 8 May 2018 20:11:45 +0000 (UTC) Received: from localhost ([::1]:53178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG8xc-0005j8-JB for patchwork-qemu-devel@patchwork.kernel.org; Tue, 08 May 2018 16:11:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG8vE-0003jm-Eg for qemu-devel@nongnu.org; Tue, 08 May 2018 16:09:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG8vD-0004wN-1j for qemu-devel@nongnu.org; Tue, 08 May 2018 16:09:16 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:39276) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG8vC-0004w4-Re for qemu-devel@nongnu.org; Tue, 08 May 2018 16:09:14 -0400 Received: by mail-pl0-x242.google.com with SMTP id c19-v6so49914pls.6 for ; Tue, 08 May 2018 13:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=47yxZp5RQJisSZM6EmazIPkrCG4NFFd5tAx3HJkDg/8=; b=bVBnty1YzqQfTT85g8TzsNH/hCjdyOt543HdzDzyq6/utbybzxfuyscbQZMR5t1yNp J6lX5mCaVDttgpTG5XGE+24G4QLZgauFhtTGtvbcRZzy8Jm5zHOaFzWtVhvtCYMsSceO o+7BdoRSu99vJ3pW6cleC1mvhxXc5oqoHyZiVUwnfThDZO0gQQfWhv0ZWdFGPMO5R5Ig 9tmvWK/E04+DDXstdC4ltZk0KKZsl9vTrKW6ZNk8R5frCUz4gNx8kbJIe/76hnDZP08a uRvyQO6LZLlVlEAZA8wgPEa/FQjDD3+sX5JXbdG/6pFsnGTqhPBJqxyF1HIOF7mL411Y zmLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=47yxZp5RQJisSZM6EmazIPkrCG4NFFd5tAx3HJkDg/8=; b=mi29P8tTRrZU3uVaW+zKJZhZGcWgsXtJcN/AoHmWfkQ+KEQZc0ynxcDqK6OXbbWAJd aLh7Y5DRBLm7SPWgYoYYzjo7IaIu6ZijR0Nynz1ghgWIHxtAg0BHxMc2Mpe7LYz7t7e4 cHSh29L/CAggZGyeOJggZwiMgSEAYxSDsJWpHgWXpDjm0GzIk8pbNshDjyVDbkWqItYB NSZZDzJznL9G8ECLh3JythFYy1EK4InX1ieMEsWlXPaQn08vHFTmbcg3Qx+7wtc+zhfY wcWfrv1ntjGTzW6yJvwAvDAb1HwH1XIiM4ySKyPFkeDOt396Kc4o351py7bioivhxQDQ +Sxg== X-Gm-Message-State: ALQs6tBOXPr93DzAb4C8LBhKqobQK6m2yPgDhoopPSKTbnO6NkXWJFrT UsvNsFbsgrehX/sUIEN646H+vx1LVH0= X-Google-Smtp-Source: AB8JxZqf2bXSmEM5fXD9ynGKnbx2j2gFJyhSxI8UxfxyjlIGTwZI91zfktJp2tTL36ULNoBY4PpCIw== X-Received: by 2002:a17:902:5597:: with SMTP id g23-v6mr42944055pli.347.1525810153908; Tue, 08 May 2018 13:09:13 -0700 (PDT) Received: from localhost.localdomain (122-58-167-38-fibre.bb.spark.co.nz. [122.58.167.38]) by smtp.gmail.com with ESMTPSA id g16-v6sm205171pgn.51.2018.05.08.13.09.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 May 2018 13:09:13 -0700 (PDT) From: Michael Clark To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 08:07:38 +1200 Message-Id: <1525810060-36690-2-git-send-email-mjc@sifive.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1525810060-36690-1-git-send-email-mjc@sifive.com> References: <1525810060-36690-1-git-send-email-mjc@sifive.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL 1/3] riscv: spike: allow base == 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@groups.riscv.org, KONRAD Frederic , Michael Clark Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: KONRAD Frederic The sanity check on base doesn't allow htif to be mapped @0. Check if the symbol exists instead so we can map it where we want. Reviewed-by: Michael Clark Signed-off-by: KONRAD Frederic Signed-off-by: Michael Clark Message-Id: <1525360636-18229-2-git-send-email-frederic.konrad@adacore.com> --- hw/riscv/riscv_htif.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/riscv/riscv_htif.c b/hw/riscv/riscv_htif.c index 3e17f3025106..be252ec8cce9 100644 --- a/hw/riscv/riscv_htif.c +++ b/hw/riscv/riscv_htif.c @@ -41,17 +41,20 @@ } while (0) static uint64_t fromhost_addr, tohost_addr; +static int address_symbol_set; void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value, - uint64_t st_size) + uint64_t st_size) { if (strcmp("fromhost", st_name) == 0) { + address_symbol_set |= 1; fromhost_addr = st_value; if (st_size != 8) { error_report("HTIF fromhost must be 8 bytes"); exit(1); } } else if (strcmp("tohost", st_name) == 0) { + address_symbol_set |= 2; tohost_addr = st_value; if (st_size != 8) { error_report("HTIF tohost must be 8 bytes"); @@ -248,7 +251,7 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, htif_can_recv, htif_recv, htif_event, htif_be_change, s, NULL, true); - if (base) { + if (address_symbol_set == 3) { memory_region_init_io(&s->mmio, NULL, &htif_mm_ops, s, TYPE_HTIF_UART, size); memory_region_add_subregion(address_space, base, &s->mmio);