From patchwork Tue Nov 14 16:31:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 743793 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2268668wrw; Tue, 14 Nov 2023 08:33:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmtvXYi1hMflQWYErkt2KXmHHRDLCMyzdUVQnSB7BMqZxk8ewr4AQ7tTLSUoEHez28MaNf X-Received: by 2002:a05:620a:478c:b0:77a:955:9461 with SMTP id dt12-20020a05620a478c00b0077a09559461mr3232018qkb.14.1699979614483; Tue, 14 Nov 2023 08:33:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699979614; cv=none; d=google.com; s=arc-20160816; b=KP10jubAOTvS24An3VxzIae1WtNDg2xW4TQqWlNuHTrvZPe07Lb5IRqdDpqg7J59sD XF2fYjb+S4JWvGAsjrqW2Q+bklhUsHgvMxGktYZoGDhOtVqX7G42zgFIuw9mP0d4btYD ZPdIvDbVJWSiEWoglLPc+OQIqpqUKCWTP4WyJ0vd/5M9D7L+fVtCDIibluXWeNQMV+PQ zCHSSS+jRJ++T6fOc320UqIk73/1olyL9iKXGB8SdtFTEJnGPryQ1wlgu2c40e155ijT lucZ5NyZ0mBhcLNdznVWhYq9ClNRsiIWuRBvj/H5C/BIHZSMEvppxwL86SaMOrgASlzY dddA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=htjkOQmTZcMenhXqLaaInIEhXImv4mUPxpJWcjUwWD8=; fh=9pdq7NpBxJPnvyNu1sJsWepRx2HfUbiacvC5FeL2cfI=; b=J8ewZdyY1A/wuSz14NNy4vZyZb4cioMz+StR54J3R/5eWAfuU/jGrI68CzqkZkF3vn k9MDYLhlg2QR+bdpfNXvpiinhugQ8pK3jfJ9vBaiN/tcmCRyddm6FTbuvxPPT4XAJI1H 5PzvdQsqf+Bttk8rEHhxjK/utwXVnfPDA78PNAydgATv+D6fVDAixoDTARCp58JfgiHR 9QgCY0j3XxPOWCsTb9d73E7BBtWPzKRB7Owa5Bs/9SDSTPMuuNIf+3wQUwzG2lwFS0jq rgqLU/oJJ4KLejr0vMADb72Dep49pZlGRMZeKi3t1ImmyU+GRhc0SugdFn7DOhvaSmf9 +FkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXUpAG5U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bn44-20020a05620a2aec00b0077758455319si6905587qkb.764.2023.11.14.08.33.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2023 08:33:34 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXUpAG5U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2wLO-000486-54; Tue, 14 Nov 2023 11:32:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r2wKy-0003KW-5i for qemu-devel@nongnu.org; Tue, 14 Nov 2023 11:32:32 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r2wKt-0006eG-Uf for qemu-devel@nongnu.org; Tue, 14 Nov 2023 11:32:25 -0500 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9e62f903e88so645816366b.2 for ; Tue, 14 Nov 2023 08:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699979542; x=1700584342; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=htjkOQmTZcMenhXqLaaInIEhXImv4mUPxpJWcjUwWD8=; b=qXUpAG5U7kUwBh7IMiLEJsYIq5hU3iSNPyp6nnd/GvrOCa+JwebR/jRbvB+C1i6COH lhngntDiU+SVMBI5qXxB6MQ9fnGFtPyrZTd1Vv9bN29WF/PYYaFU+H2S30vjNaahQAqZ tXdLcXV3bluM5jc9mYWibcXKEq401pZGfXhhUzX4TJb4Gj5XqorNsc520tXs8oiePSW6 k/YzjHfvd+0zfIEMCkSqrCfribLuBNnTswYAQeV8Yg1YfQ7VXo1elCmNRUf9TkCFHYz5 fgXmSz71MbLORvFAosRuFr2GuaEhCf7KknGxnkRn52snJmHsiT5K3t0dfWqq0m9jFhge vAyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699979542; x=1700584342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=htjkOQmTZcMenhXqLaaInIEhXImv4mUPxpJWcjUwWD8=; b=vQXgQ/52JAtVpAbitspi7qvrOM+ipuqiSYhcqHKdA8SJxnHxCFFuSMOlmqKBCyMfGS i0oedCBHVB8bMIaYpETJB8jxtRzhyN3inQHhWzwfP0sssqFGzF48FEF71GC/Cdbeudtj KpuS0FUS3O/4YToyF7rhYCDejJpuZxdRrJYbNgAvyT3tHBBEKOqHaq/14yrvxunE8dp4 1b9xDcyzD1ET2dqPJypfJszaJdAGZfeGr7tpBieztfyKHLWC+klUwHe9/YFhOLFXWXAH W1y9clZlA75dSqu5QOcaFTWQTpr66ELH0Jr3vWdnVSxQYYwYU/6PSLD2MGzQYBIiBdRE xK6Q== X-Gm-Message-State: AOJu0YwRQvKdvA80DlKfVBzTGT2tMvUj3Waq+BWkXJTK1mQ9Kx56P2LB Hz/gAengCku+o8zcSxblfteKy9m/iYG3rlgnWRY= X-Received: by 2002:a17:906:7943:b0:9d3:e48f:30d3 with SMTP id l3-20020a170906794300b009d3e48f30d3mr9901673ejo.31.1699979542369; Tue, 14 Nov 2023 08:32:22 -0800 (PST) Received: from m1x-phil.lan (cac94-h02-176-184-25-155.dsl.sta.abo.bbox.fr. [176.184.25.155]) by smtp.gmail.com with ESMTPSA id c26-20020a17090603da00b009adce1c97ccsm5731084eja.53.2023.11.14.08.32.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Nov 2023 08:32:21 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Anthony Perard , Paul Durrant , David Woodhouse , Thomas Huth , qemu-arm@nongnu.org, Stefano Stabellini , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , xen-devel@lists.xenproject.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 9/9] hw/xen/hvm: Inline xen_arch_set_memory() Date: Tue, 14 Nov 2023 17:31:23 +0100 Message-ID: <20231114163123.74888-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231114163123.74888-1-philmd@linaro.org> References: <20231114163123.74888-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philmd@linaro.org; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org xen_arch_set_memory() is not arch-specific anymore. Being called once, inline it in xen_set_memory(). Signed-off-by: Philippe Mathieu-Daudé --- include/hw/xen/xen-hvm-common.h | 3 - hw/xen/xen-hvm-common.c | 104 ++++++++++++++++---------------- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/include/hw/xen/xen-hvm-common.h b/include/hw/xen/xen-hvm-common.h index 536712dc83..a1b8a2783b 100644 --- a/include/hw/xen/xen-hvm-common.h +++ b/include/hw/xen/xen-hvm-common.h @@ -99,8 +99,5 @@ void cpu_ioreq_pio(ioreq_t *req); void xen_read_physmap(XenIOState *state); void xen_arch_handle_ioreq(XenIOState *state, ioreq_t *req); -void xen_arch_set_memory(XenIOState *state, - MemoryRegionSection *section, - bool add); #endif /* HW_XEN_HVM_COMMON_H */ diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 50ce45effc..789c6b4b7a 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -426,50 +426,6 @@ void qmp_xen_set_global_dirty_log(bool enable, Error **errp) } } -void xen_arch_set_memory(XenIOState *state, MemoryRegionSection *section, - bool add) -{ - unsigned target_page_bits = qemu_target_page_bits(); - int page_size = qemu_target_page_size(); - int page_mask = -page_size; - hwaddr start_addr = section->offset_within_address_space; - ram_addr_t size = int128_get64(section->size); - bool log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); - hvmmem_type_t mem_type; - - if (!memory_region_is_ram(section->mr)) { - return; - } - - if (log_dirty != add) { - return; - } - - trace_xen_client_set_memory(start_addr, size, log_dirty); - - start_addr &= page_mask; - size = ROUND_UP(size, page_size); - - if (add) { - if (!memory_region_is_rom(section->mr)) { - xen_add_to_physmap(state, start_addr, size, - section->mr, section->offset_within_region); - } else { - mem_type = HVMMEM_ram_ro; - if (xen_set_mem_type(xen_domid, mem_type, - start_addr >> target_page_bits, - size >> target_page_bits)) { - DPRINTF("xen_set_mem_type error, addr: "HWADDR_FMT_plx"\n", - start_addr); - } - } - } else { - if (xen_remove_from_physmap(state, start_addr, size) < 0) { - DPRINTF("physmapping does not exist at "HWADDR_FMT_plx"\n", start_addr); - } - } -} - void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, Error **errp) { @@ -512,20 +468,62 @@ static void xen_set_memory(struct MemoryListener *listener, bool add) { XenIOState *state = container_of(listener, XenIOState, memory_listener); + unsigned target_page_bits = qemu_target_page_bits(); + int page_size = qemu_target_page_size(); + int page_mask = -page_size; + hwaddr start_addr; + ram_addr_t size; + bool log_dirty; + hvmmem_type_t mem_type; + if (section->mr == &xen_memory) { return; - } else { - if (add) { - xen_map_memory_section(xen_domid, state->ioservid, - section); - } else { - xen_unmap_memory_section(xen_domid, state->ioservid, - section); - } } - xen_arch_set_memory(state, section, add); + if (add) { + xen_map_memory_section(xen_domid, state->ioservid, + section); + } else { + xen_unmap_memory_section(xen_domid, state->ioservid, + section); + } + + if (!memory_region_is_ram(section->mr)) { + return; + } + + log_dirty = memory_region_is_logging(section->mr, DIRTY_MEMORY_VGA); + + if (log_dirty != add) { + return; + } + + start_addr = section->offset_within_address_space; + size = int128_get64(section->size); + trace_xen_client_set_memory(start_addr, size, log_dirty); + + start_addr &= page_mask; + size = ROUND_UP(size, page_size); + + if (add) { + if (!memory_region_is_rom(section->mr)) { + xen_add_to_physmap(state, start_addr, size, + section->mr, section->offset_within_region); + } else { + mem_type = HVMMEM_ram_ro; + if (xen_set_mem_type(xen_domid, mem_type, + start_addr >> target_page_bits, + size >> target_page_bits)) { + DPRINTF("xen_set_mem_type error, addr: "HWADDR_FMT_plx"\n", + start_addr); + } + } + } else { + if (xen_remove_from_physmap(state, start_addr, size) < 0) { + DPRINTF("physmapping does not exist at "HWADDR_FMT_plx"\n", start_addr); + } + } } void xen_region_add(MemoryListener *listener,