Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp362416imm; Thu, 14 Jun 2018 22:14:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLc9xF9LU3uRZl1fyHPwC0x7YMfiIcil/cPFqs58ikPVzmT1cMTWFEDfbjQchJzq4NczJ5f X-Received: by 2002:a65:538e:: with SMTP id x14-v6mr184395pgq.330.1529039675656; Thu, 14 Jun 2018 22:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529039675; cv=none; d=google.com; s=arc-20160816; b=y/GRNO0MK+ucPJ2P8zw6AzrEAgOjmGtvDyLtzK2DFaL86m6gRk+FaF2x7wkeeaytwj /6aCf/NpTxBJrwl7uwSmC0SN8PHkNXVHBtr2fK7+4xhwLRo6fbzrk5nDnFjYnGvlRcnf PW986gjjxJS0xdWWhqIDQhl/TfB+0ODhh92oP2Auri4gNOp0E/PGD8KGK4ECFQzp0WDL PWg8rT4oKcIW6LOBsZdBF/t9bhnbWfB/N15riZR14duLxT5/8kVviZt6/FJos+ModAGo cW9WB1bmfejMzIQ3gNLAhW3XEocbi6ZyJTVttf1AaEshIEnCCp8Q4Er79ZHSJ6FkOKKK efbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OG/FXLccYMA6EWcYYsXr5Y12eqX5mZA9cfSm/yew5CY=; b=oObTEoqcdMQ+y1/Vacw9cvsuR25IIpJz7Vu4O3yjotocM1NRpi5qYdRlfM1BHQVkSu gKOlWomKQkN/BTf5z6uWBApfuBte+YnmJ1F7Ga+tzv8RvKOgQT+r6mhHzrfxY0qNLrOU 3qMlR+uetqHdV8mX1KoFjZkqPbtTKyoiR0SOgdw/tCcpZI6Gt1Iv7AETNytCPBxKYVGf yLmcbQhmDQAMQpqhnPtCDNv6QZbOwKv5oP/s+CxAtOvQ8Hrqm7ISXJbVsi1mmHsWjeJ1 uFUK6DyAzGARmoudTH4Hpn0iAfztyNIGdHkrGcBjJLvdzmAzDmNtcqVI0a5U7+xC/el/ uCFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33-v6si7030857pld.170.2018.06.14.22.13.51; Thu, 14 Jun 2018 22:14:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755791AbeFOFIu (ORCPT + 99 others); Fri, 15 Jun 2018 01:08:50 -0400 Received: from mga12.intel.com ([192.55.52.136]:33117 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755749AbeFOFIq (ORCPT ); Fri, 15 Jun 2018 01:08:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jun 2018 22:08:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,225,1526367600"; d="scan'208";a="47272205" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by fmsmga007.fm.intel.com with ESMTP; 14 Jun 2018 22:08:43 -0700 From: Wei Wang To: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pbonzini@redhat.com, wei.w.wang@intel.com, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, riel@redhat.com, peterx@redhat.com Subject: [PATCH v33 4/4] virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON Date: Fri, 15 Jun 2018 12:43:13 +0800 Message-Id: <1529037793-35521-5-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529037793-35521-1-git-send-email-wei.w.wang@intel.com> References: <1529037793-35521-1-git-send-email-wei.w.wang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The VIRTIO_BALLOON_F_PAGE_POISON feature bit is used to indicate if the guest is using page poisoning. Guest writes to the poison_val config field to tell host about the page poisoning value that is in use. Suggested-by: Michael S. Tsirkin Signed-off-by: Wei Wang Cc: Michael S. Tsirkin Cc: Michal Hocko Cc: Andrew Morton --- drivers/virtio/virtio_balloon.c | 10 ++++++++++ include/uapi/linux/virtio_balloon.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 582a03b..c59bb380 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -634,6 +634,7 @@ static struct file_system_type balloon_fs = { static int virtballoon_probe(struct virtio_device *vdev) { struct virtio_balloon *vb; + __u32 poison_val; int err; if (!vdev->config->get) { @@ -671,6 +672,11 @@ static int virtballoon_probe(struct virtio_device *vdev) goto out_del_vqs; } INIT_WORK(&vb->report_free_page_work, report_free_page_func); + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) { + memset(&poison_val, PAGE_POISON, sizeof(poison_val)); + virtio_cwrite(vb->vdev, struct virtio_balloon_config, + poison_val, &poison_val); + } vb->hints = kmalloc(FREE_PAGE_HINT_MEM_SIZE, GFP_KERNEL); if (!vb->hints) { err = -ENOMEM; @@ -796,6 +802,9 @@ static int virtballoon_restore(struct virtio_device *vdev) static int virtballoon_validate(struct virtio_device *vdev) { + if (!page_poisoning_enabled()) + __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_PAGE_POISON); + __virtio_clear_bit(vdev, VIRTIO_F_IOMMU_PLATFORM); return 0; } @@ -805,6 +814,7 @@ static unsigned int features[] = { VIRTIO_BALLOON_F_STATS_VQ, VIRTIO_BALLOON_F_DEFLATE_ON_OOM, VIRTIO_BALLOON_F_FREE_PAGE_HINT, + VIRTIO_BALLOON_F_PAGE_POISON, }; static struct virtio_driver virtio_balloon_driver = { diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index 99b8416..f3b6191 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -35,6 +35,7 @@ #define VIRTIO_BALLOON_F_STATS_VQ 1 /* Memory Stats virtqueue */ #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */ #define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3 /* VQ to report free pages */ +#define VIRTIO_BALLOON_F_PAGE_POISON 4 /* Guest is using page poisoning */ /* Size of a PFN in the balloon interface. */ #define VIRTIO_BALLOON_PFN_SHIFT 12 @@ -47,6 +48,8 @@ struct virtio_balloon_config { __u32 actual; /* Command sent from host */ __u32 host_cmd; + /* Stores PAGE_POISON if page poisoning is in use */ + __u32 poison_val; }; struct virtio_balloon_free_page_hints { -- 2.7.4