From patchwork Thu Oct 10 13:50:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 11183641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 457801575 for ; Thu, 10 Oct 2019 13:52:04 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2046A2067B for ; Thu, 10 Oct 2019 13:52:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="awxd2k2/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2046A2067B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iIYq6-0006Sc-2R; Thu, 10 Oct 2019 13:50:46 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iIYq4-0006SX-VJ for xen-devel@lists.xenproject.org; Thu, 10 Oct 2019 13:50:45 +0000 X-Inumbo-ID: f41ea8ea-eb64-11e9-8aca-bc764e2007e4 Received: from mail-lf1-x142.google.com (unknown [2a00:1450:4864:20::142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f41ea8ea-eb64-11e9-8aca-bc764e2007e4; Thu, 10 Oct 2019 13:50:44 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id u3so4441935lfl.10 for ; Thu, 10 Oct 2019 06:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fhlldiEDv5prmCvD2dbgYgOko690vJc1+ajiMYBQnMQ=; b=awxd2k2/0rQZ4ivCWpZoa5liZGezT8qw3xODU9HZu6juFf9Cct76Dr4B8OUcb8G3DA GLsN83UyOL/V5rKTun0DOlC8x1UbhCmCSX66o64Qnr8bb8We/R4qb8bI3lqWT5yIgdOo 0jW2NgRQjHmL+aySfo9owt/6o/SMFpoRFPKPPnsFDbZbRLb290nd/Rzw1ZiPBQr5Hxaw /Fnx2ftojsdZEjKaOj5QHjM4Y7iGEIHqJ3gL1gM99RgvJ+aDaBCGFJWIrSNMi/YJNojI 2mm7ZvRGsH2Eno5snRp5vmowMXQCvMmfmfx/MaOh+E8Q4DHYgNO1+E21xdR1bOd2btrA Q06A== 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; bh=fhlldiEDv5prmCvD2dbgYgOko690vJc1+ajiMYBQnMQ=; b=bZLxdyg94ZwIQ57gjDEaGPMtNY9cTse+/yYTAbCsKBLtD+2I1i8DxQLbMTKZbNtdAt mzXzMHKo1VbkR1tWjBpjBcWLp3xBy8ApnZz5gCnnb9fpYwPDc9M3CGfiAPsYBYwixL61 7lcaHL7Y3aIEBurLA4HdaTzm+eluqd9hwkzFn2yv7RFY5O7o5P89eg4Km9Sfa/aO6XCQ FN/LCannnkAWrKUvzCK89VBElAtCggkX+bxVkJeRCJMBfZwrLUkZnDfY6/VyXcQlheVz GXJAyLdeTOaU5ZBBSx5T9TczI14PrVpMHmumGitxaKfwZrXAd8IFjWSrcQrPi1/5dp9j kSRw== X-Gm-Message-State: APjAAAXZ3NM0LQaqeZ0grQmUel5wDzdwA4bBDb6sDWpbAhJ55s6RvkMW DZWrosteiwntYVt9cEjOCLK/QzyT04Y= X-Google-Smtp-Source: APXvYqz6fUU/psEhzxVk4PbE5ZKCIj8pxv2h9k3BE84IKDd/yqiqUTV4p784K4R/+Atx9IEz/t8uqQ== X-Received: by 2002:ac2:5629:: with SMTP id b9mr6477624lff.32.1570715442828; Thu, 10 Oct 2019 06:50:42 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id m18sm1265294lfb.73.2019.10.10.06.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 06:50:42 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 10 Oct 2019 16:50:04 +0300 Message-Id: <20191010135004.24226-1-al1img@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH v1] Reset iomem's gfn to LIBXL_INVALID_GFN on reboot X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: ian.jackson@eu.citrix.com, wl@xen.org, Oleksandr Andrushchenko MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko During domain reboot its configuration is partially reused to re-create a new domain, but iomem's GFN field for the iomem is only restored for those memory ranges, which are configured in form of [IOMEM_START,NUM_PAGES[@GFN], but not for those in form of [IOMEM_START,NUM_PAGES], e.g. without GFN. For the latter GFN is reset to 0, but while mapping ranges to a domain during reboot there is a check that GFN treated as valid if it is not equal to LIBXL_INVALID_GFN, thus making Xen to map IOMEM_START to address 0 in the guest's address space. Workaround it by resseting GFN to LIBXL_INVALID_GFN, so xl can set proper values for mapping on reboot. Signed-off-by: Oleksandr Andrushchenko --- tools/libxl/libxl_domain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 9d0eb5aed1..0ae16a5b12 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -2120,6 +2120,15 @@ static void retrieve_domain_configuration_end(libxl__egc *egc, } } + /* reset IOMEM's GFN to initial value */ + { + int i; + + for (i = 0; i < d_config->b_info.num_iomem; i++) + if (d_config->b_info.iomem[i].gfn == 0) + d_config->b_info.iomem[i].gfn = LIBXL_INVALID_GFN; + } + /* Devices: disk, nic, vtpm, pcidev etc. */ /* The MERGE macro implements following logic: