Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull virtio/vhost updates from Michael Tsirkin:
"Fixes and tweaks:

- virtio balloon page hinting support

- vhost scsi control queue

- misc fixes"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
MAINTAINERS: remove reference to bogus vsock file
vhost/scsi: Use common handling code in request queue handler
vhost/scsi: Extract common handling code from control queue handler
vhost/scsi: Respond to control queue operations
vhost/scsi: truncate T10 PI iov_iter to prot_bytes
virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON
mm/page_poison: expose page_poisoning_enabled to kernel modules
virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT
kvm_config: add CONFIG_VIRTIO_MENU

+688 -134
-1
MAINTAINERS
··· 15858 15858 F: net/vmw_vsock/virtio_transport.c 15859 15859 F: drivers/net/vsockmon.c 15860 15860 F: drivers/vhost/vsock.c 15861 - F: drivers/vhost/vsock.h 15862 15861 F: tools/testing/vsock/ 15863 15862 15864 15863 VIRTIO CONSOLE DRIVER
+329 -97
drivers/vhost/scsi.c
··· 203 203 int vs_events_nr; /* num of pending events, protected by vq->mutex */ 204 204 }; 205 205 206 + /* 207 + * Context for processing request and control queue operations. 208 + */ 209 + struct vhost_scsi_ctx { 210 + int head; 211 + unsigned int out, in; 212 + size_t req_size, rsp_size; 213 + size_t out_size, in_size; 214 + u8 *target, *lunp; 215 + void *req; 216 + struct iov_iter out_iter; 217 + }; 218 + 206 219 static struct workqueue_struct *vhost_scsi_workqueue; 207 220 208 221 /* Global spinlock to protect vhost_scsi TPG list for vhost IOCTL access */ ··· 813 800 pr_err("Faulted on virtio_scsi_cmd_resp\n"); 814 801 } 815 802 803 + static int 804 + vhost_scsi_get_desc(struct vhost_scsi *vs, struct vhost_virtqueue *vq, 805 + struct vhost_scsi_ctx *vc) 806 + { 807 + int ret = -ENXIO; 808 + 809 + vc->head = vhost_get_vq_desc(vq, vq->iov, 810 + ARRAY_SIZE(vq->iov), &vc->out, &vc->in, 811 + NULL, NULL); 812 + 813 + pr_debug("vhost_get_vq_desc: head: %d, out: %u in: %u\n", 814 + vc->head, vc->out, vc->in); 815 + 816 + /* On error, stop handling until the next kick. */ 817 + if (unlikely(vc->head < 0)) 818 + goto done; 819 + 820 + /* Nothing new? Wait for eventfd to tell us they refilled. */ 821 + if (vc->head == vq->num) { 822 + if (unlikely(vhost_enable_notify(&vs->dev, vq))) { 823 + vhost_disable_notify(&vs->dev, vq); 824 + ret = -EAGAIN; 825 + } 826 + goto done; 827 + } 828 + 829 + /* 830 + * Get the size of request and response buffers. 831 + * FIXME: Not correct for BIDI operation 832 + */ 833 + vc->out_size = iov_length(vq->iov, vc->out); 834 + vc->in_size = iov_length(&vq->iov[vc->out], vc->in); 835 + 836 + /* 837 + * Copy over the virtio-scsi request header, which for a 838 + * ANY_LAYOUT enabled guest may span multiple iovecs, or a 839 + * single iovec may contain both the header + outgoing 840 + * WRITE payloads. 841 + * 842 + * copy_from_iter() will advance out_iter, so that it will 843 + * point at the start of the outgoing WRITE payload, if 844 + * DMA_TO_DEVICE is set. 845 + */ 846 + iov_iter_init(&vc->out_iter, WRITE, vq->iov, vc->out, vc->out_size); 847 + ret = 0; 848 + 849 + done: 850 + return ret; 851 + } 852 + 853 + static int 854 + vhost_scsi_chk_size(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc) 855 + { 856 + if (unlikely(vc->in_size < vc->rsp_size)) { 857 + vq_err(vq, 858 + "Response buf too small, need min %zu bytes got %zu", 859 + vc->rsp_size, vc->in_size); 860 + return -EINVAL; 861 + } else if (unlikely(vc->out_size < vc->req_size)) { 862 + vq_err(vq, 863 + "Request buf too small, need min %zu bytes got %zu", 864 + vc->req_size, vc->out_size); 865 + return -EIO; 866 + } 867 + 868 + return 0; 869 + } 870 + 871 + static int 872 + vhost_scsi_get_req(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc, 873 + struct vhost_scsi_tpg **tpgp) 874 + { 875 + int ret = -EIO; 876 + 877 + if (unlikely(!copy_from_iter_full(vc->req, vc->req_size, 878 + &vc->out_iter))) { 879 + vq_err(vq, "Faulted on copy_from_iter\n"); 880 + } else if (unlikely(*vc->lunp != 1)) { 881 + /* virtio-scsi spec requires byte 0 of the lun to be 1 */ 882 + vq_err(vq, "Illegal virtio-scsi lun: %u\n", *vc->lunp); 883 + } else { 884 + struct vhost_scsi_tpg **vs_tpg, *tpg; 885 + 886 + vs_tpg = vq->private_data; /* validated at handler entry */ 887 + 888 + tpg = READ_ONCE(vs_tpg[*vc->target]); 889 + if (unlikely(!tpg)) { 890 + vq_err(vq, "Target 0x%x does not exist\n", *vc->target); 891 + } else { 892 + if (tpgp) 893 + *tpgp = tpg; 894 + ret = 0; 895 + } 896 + } 897 + 898 + return ret; 899 + } 900 + 816 901 static void 817 902 vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) 818 903 { 819 904 struct vhost_scsi_tpg **vs_tpg, *tpg; 820 905 struct virtio_scsi_cmd_req v_req; 821 906 struct virtio_scsi_cmd_req_pi v_req_pi; 907 + struct vhost_scsi_ctx vc; 822 908 struct vhost_scsi_cmd *cmd; 823 - struct iov_iter out_iter, in_iter, prot_iter, data_iter; 909 + struct iov_iter in_iter, prot_iter, data_iter; 824 910 u64 tag; 825 911 u32 exp_data_len, data_direction; 826 - unsigned int out = 0, in = 0; 827 - int head, ret, prot_bytes; 828 - size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp); 829 - size_t out_size, in_size; 912 + int ret, prot_bytes; 830 913 u16 lun; 831 - u8 *target, *lunp, task_attr; 914 + u8 task_attr; 832 915 bool t10_pi = vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI); 833 - void *req, *cdb; 916 + void *cdb; 834 917 835 918 mutex_lock(&vq->mutex); 836 919 /* ··· 937 828 if (!vs_tpg) 938 829 goto out; 939 830 831 + memset(&vc, 0, sizeof(vc)); 832 + vc.rsp_size = sizeof(struct virtio_scsi_cmd_resp); 833 + 940 834 vhost_disable_notify(&vs->dev, vq); 941 835 942 836 for (;;) { 943 - head = vhost_get_vq_desc(vq, vq->iov, 944 - ARRAY_SIZE(vq->iov), &out, &in, 945 - NULL, NULL); 946 - pr_debug("vhost_get_vq_desc: head: %d, out: %u in: %u\n", 947 - head, out, in); 948 - /* On error, stop handling until the next kick. */ 949 - if (unlikely(head < 0)) 950 - break; 951 - /* Nothing new? Wait for eventfd to tell us they refilled. */ 952 - if (head == vq->num) { 953 - if (unlikely(vhost_enable_notify(&vs->dev, vq))) { 954 - vhost_disable_notify(&vs->dev, vq); 955 - continue; 956 - } 957 - break; 958 - } 959 - /* 960 - * Check for a sane response buffer so we can report early 961 - * errors back to the guest. 962 - */ 963 - if (unlikely(vq->iov[out].iov_len < rsp_size)) { 964 - vq_err(vq, "Expecting at least virtio_scsi_cmd_resp" 965 - " size, got %zu bytes\n", vq->iov[out].iov_len); 966 - break; 967 - } 837 + ret = vhost_scsi_get_desc(vs, vq, &vc); 838 + if (ret) 839 + goto err; 840 + 968 841 /* 969 842 * Setup pointers and values based upon different virtio-scsi 970 843 * request header if T10_PI is enabled in KVM guest. 971 844 */ 972 845 if (t10_pi) { 973 - req = &v_req_pi; 974 - req_size = sizeof(v_req_pi); 975 - lunp = &v_req_pi.lun[0]; 976 - target = &v_req_pi.lun[1]; 846 + vc.req = &v_req_pi; 847 + vc.req_size = sizeof(v_req_pi); 848 + vc.lunp = &v_req_pi.lun[0]; 849 + vc.target = &v_req_pi.lun[1]; 977 850 } else { 978 - req = &v_req; 979 - req_size = sizeof(v_req); 980 - lunp = &v_req.lun[0]; 981 - target = &v_req.lun[1]; 851 + vc.req = &v_req; 852 + vc.req_size = sizeof(v_req); 853 + vc.lunp = &v_req.lun[0]; 854 + vc.target = &v_req.lun[1]; 982 855 } 983 - /* 984 - * FIXME: Not correct for BIDI operation 985 - */ 986 - out_size = iov_length(vq->iov, out); 987 - in_size = iov_length(&vq->iov[out], in); 988 856 989 857 /* 990 - * Copy over the virtio-scsi request header, which for a 991 - * ANY_LAYOUT enabled guest may span multiple iovecs, or a 992 - * single iovec may contain both the header + outgoing 993 - * WRITE payloads. 994 - * 995 - * copy_from_iter() will advance out_iter, so that it will 996 - * point at the start of the outgoing WRITE payload, if 997 - * DMA_TO_DEVICE is set. 858 + * Validate the size of request and response buffers. 859 + * Check for a sane response buffer so we can report 860 + * early errors back to the guest. 998 861 */ 999 - iov_iter_init(&out_iter, WRITE, vq->iov, out, out_size); 862 + ret = vhost_scsi_chk_size(vq, &vc); 863 + if (ret) 864 + goto err; 1000 865 1001 - if (unlikely(!copy_from_iter_full(req, req_size, &out_iter))) { 1002 - vq_err(vq, "Faulted on copy_from_iter\n"); 1003 - vhost_scsi_send_bad_target(vs, vq, head, out); 1004 - continue; 1005 - } 1006 - /* virtio-scsi spec requires byte 0 of the lun to be 1 */ 1007 - if (unlikely(*lunp != 1)) { 1008 - vq_err(vq, "Illegal virtio-scsi lun: %u\n", *lunp); 1009 - vhost_scsi_send_bad_target(vs, vq, head, out); 1010 - continue; 1011 - } 866 + ret = vhost_scsi_get_req(vq, &vc, &tpg); 867 + if (ret) 868 + goto err; 1012 869 1013 - tpg = READ_ONCE(vs_tpg[*target]); 1014 - if (unlikely(!tpg)) { 1015 - /* Target does not exist, fail the request */ 1016 - vhost_scsi_send_bad_target(vs, vq, head, out); 1017 - continue; 1018 - } 870 + ret = -EIO; /* bad target on any error from here on */ 871 + 1019 872 /* 1020 873 * Determine data_direction by calculating the total outgoing 1021 874 * iovec sizes + incoming iovec sizes vs. virtio-scsi request + ··· 995 924 */ 996 925 prot_bytes = 0; 997 926 998 - if (out_size > req_size) { 927 + if (vc.out_size > vc.req_size) { 999 928 data_direction = DMA_TO_DEVICE; 1000 - exp_data_len = out_size - req_size; 1001 - data_iter = out_iter; 1002 - } else if (in_size > rsp_size) { 929 + exp_data_len = vc.out_size - vc.req_size; 930 + data_iter = vc.out_iter; 931 + } else if (vc.in_size > vc.rsp_size) { 1003 932 data_direction = DMA_FROM_DEVICE; 1004 - exp_data_len = in_size - rsp_size; 933 + exp_data_len = vc.in_size - vc.rsp_size; 1005 934 1006 - iov_iter_init(&in_iter, READ, &vq->iov[out], in, 1007 - rsp_size + exp_data_len); 1008 - iov_iter_advance(&in_iter, rsp_size); 935 + iov_iter_init(&in_iter, READ, &vq->iov[vc.out], vc.in, 936 + vc.rsp_size + exp_data_len); 937 + iov_iter_advance(&in_iter, vc.rsp_size); 1009 938 data_iter = in_iter; 1010 939 } else { 1011 940 data_direction = DMA_NONE; ··· 1021 950 if (data_direction != DMA_TO_DEVICE) { 1022 951 vq_err(vq, "Received non zero pi_bytesout," 1023 952 " but wrong data_direction\n"); 1024 - vhost_scsi_send_bad_target(vs, vq, head, out); 1025 - continue; 953 + goto err; 1026 954 } 1027 955 prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesout); 1028 956 } else if (v_req_pi.pi_bytesin) { 1029 957 if (data_direction != DMA_FROM_DEVICE) { 1030 958 vq_err(vq, "Received non zero pi_bytesin," 1031 959 " but wrong data_direction\n"); 1032 - vhost_scsi_send_bad_target(vs, vq, head, out); 1033 - continue; 960 + goto err; 1034 961 } 1035 962 prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesin); 1036 963 } 1037 964 /* 1038 - * Set prot_iter to data_iter, and advance past any 965 + * Set prot_iter to data_iter and truncate it to 966 + * prot_bytes, and advance data_iter past any 1039 967 * preceeding prot_bytes that may be present. 1040 968 * 1041 969 * Also fix up the exp_data_len to reflect only the ··· 1043 973 if (prot_bytes) { 1044 974 exp_data_len -= prot_bytes; 1045 975 prot_iter = data_iter; 976 + iov_iter_truncate(&prot_iter, prot_bytes); 1046 977 iov_iter_advance(&data_iter, prot_bytes); 1047 978 } 1048 979 tag = vhost64_to_cpu(vq, v_req_pi.tag); ··· 1067 996 vq_err(vq, "Received SCSI CDB with command_size: %d that" 1068 997 " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n", 1069 998 scsi_command_size(cdb), VHOST_SCSI_MAX_CDB_SIZE); 1070 - vhost_scsi_send_bad_target(vs, vq, head, out); 1071 - continue; 999 + goto err; 1072 1000 } 1073 1001 cmd = vhost_scsi_get_tag(vq, tpg, cdb, tag, lun, task_attr, 1074 1002 exp_data_len + prot_bytes, ··· 1075 1005 if (IS_ERR(cmd)) { 1076 1006 vq_err(vq, "vhost_scsi_get_tag failed %ld\n", 1077 1007 PTR_ERR(cmd)); 1078 - vhost_scsi_send_bad_target(vs, vq, head, out); 1079 - continue; 1008 + goto err; 1080 1009 } 1081 1010 cmd->tvc_vhost = vs; 1082 1011 cmd->tvc_vq = vq; 1083 - cmd->tvc_resp_iov = vq->iov[out]; 1084 - cmd->tvc_in_iovs = in; 1012 + cmd->tvc_resp_iov = vq->iov[vc.out]; 1013 + cmd->tvc_in_iovs = vc.in; 1085 1014 1086 1015 pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n", 1087 1016 cmd->tvc_cdb[0], cmd->tvc_lun); ··· 1088 1019 " %d\n", cmd, exp_data_len, prot_bytes, data_direction); 1089 1020 1090 1021 if (data_direction != DMA_NONE) { 1091 - ret = vhost_scsi_mapal(cmd, 1092 - prot_bytes, &prot_iter, 1093 - exp_data_len, &data_iter); 1094 - if (unlikely(ret)) { 1022 + if (unlikely(vhost_scsi_mapal(cmd, prot_bytes, 1023 + &prot_iter, exp_data_len, 1024 + &data_iter))) { 1095 1025 vq_err(vq, "Failed to map iov to sgl\n"); 1096 1026 vhost_scsi_release_cmd(&cmd->tvc_se_cmd); 1097 - vhost_scsi_send_bad_target(vs, vq, head, out); 1098 - continue; 1027 + goto err; 1099 1028 } 1100 1029 } 1101 1030 /* ··· 1101 1034 * complete the virtio-scsi request in TCM callback context via 1102 1035 * vhost_scsi_queue_data_in() and vhost_scsi_queue_status() 1103 1036 */ 1104 - cmd->tvc_vq_desc = head; 1037 + cmd->tvc_vq_desc = vc.head; 1105 1038 /* 1106 1039 * Dispatch cmd descriptor for cmwq execution in process 1107 1040 * context provided by vhost_scsi_workqueue. This also ensures ··· 1110 1043 */ 1111 1044 INIT_WORK(&cmd->work, vhost_scsi_submission_work); 1112 1045 queue_work(vhost_scsi_workqueue, &cmd->work); 1046 + ret = 0; 1047 + err: 1048 + /* 1049 + * ENXIO: No more requests, or read error, wait for next kick 1050 + * EINVAL: Invalid response buffer, drop the request 1051 + * EIO: Respond with bad target 1052 + * EAGAIN: Pending request 1053 + */ 1054 + if (ret == -ENXIO) 1055 + break; 1056 + else if (ret == -EIO) 1057 + vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); 1058 + } 1059 + out: 1060 + mutex_unlock(&vq->mutex); 1061 + } 1062 + 1063 + static void 1064 + vhost_scsi_send_tmf_reject(struct vhost_scsi *vs, 1065 + struct vhost_virtqueue *vq, 1066 + struct vhost_scsi_ctx *vc) 1067 + { 1068 + struct virtio_scsi_ctrl_tmf_resp __user *resp; 1069 + struct virtio_scsi_ctrl_tmf_resp rsp; 1070 + int ret; 1071 + 1072 + pr_debug("%s\n", __func__); 1073 + memset(&rsp, 0, sizeof(rsp)); 1074 + rsp.response = VIRTIO_SCSI_S_FUNCTION_REJECTED; 1075 + resp = vq->iov[vc->out].iov_base; 1076 + ret = __copy_to_user(resp, &rsp, sizeof(rsp)); 1077 + if (!ret) 1078 + vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0); 1079 + else 1080 + pr_err("Faulted on virtio_scsi_ctrl_tmf_resp\n"); 1081 + } 1082 + 1083 + static void 1084 + vhost_scsi_send_an_resp(struct vhost_scsi *vs, 1085 + struct vhost_virtqueue *vq, 1086 + struct vhost_scsi_ctx *vc) 1087 + { 1088 + struct virtio_scsi_ctrl_an_resp __user *resp; 1089 + struct virtio_scsi_ctrl_an_resp rsp; 1090 + int ret; 1091 + 1092 + pr_debug("%s\n", __func__); 1093 + memset(&rsp, 0, sizeof(rsp)); /* event_actual = 0 */ 1094 + rsp.response = VIRTIO_SCSI_S_OK; 1095 + resp = vq->iov[vc->out].iov_base; 1096 + ret = __copy_to_user(resp, &rsp, sizeof(rsp)); 1097 + if (!ret) 1098 + vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0); 1099 + else 1100 + pr_err("Faulted on virtio_scsi_ctrl_an_resp\n"); 1101 + } 1102 + 1103 + static void 1104 + vhost_scsi_ctl_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) 1105 + { 1106 + union { 1107 + __virtio32 type; 1108 + struct virtio_scsi_ctrl_an_req an; 1109 + struct virtio_scsi_ctrl_tmf_req tmf; 1110 + } v_req; 1111 + struct vhost_scsi_ctx vc; 1112 + size_t typ_size; 1113 + int ret; 1114 + 1115 + mutex_lock(&vq->mutex); 1116 + /* 1117 + * We can handle the vq only after the endpoint is setup by calling the 1118 + * VHOST_SCSI_SET_ENDPOINT ioctl. 1119 + */ 1120 + if (!vq->private_data) 1121 + goto out; 1122 + 1123 + memset(&vc, 0, sizeof(vc)); 1124 + 1125 + vhost_disable_notify(&vs->dev, vq); 1126 + 1127 + for (;;) { 1128 + ret = vhost_scsi_get_desc(vs, vq, &vc); 1129 + if (ret) 1130 + goto err; 1131 + 1132 + /* 1133 + * Get the request type first in order to setup 1134 + * other parameters dependent on the type. 1135 + */ 1136 + vc.req = &v_req.type; 1137 + typ_size = sizeof(v_req.type); 1138 + 1139 + if (unlikely(!copy_from_iter_full(vc.req, typ_size, 1140 + &vc.out_iter))) { 1141 + vq_err(vq, "Faulted on copy_from_iter tmf type\n"); 1142 + /* 1143 + * The size of the response buffer depends on the 1144 + * request type and must be validated against it. 1145 + * Since the request type is not known, don't send 1146 + * a response. 1147 + */ 1148 + continue; 1149 + } 1150 + 1151 + switch (v_req.type) { 1152 + case VIRTIO_SCSI_T_TMF: 1153 + vc.req = &v_req.tmf; 1154 + vc.req_size = sizeof(struct virtio_scsi_ctrl_tmf_req); 1155 + vc.rsp_size = sizeof(struct virtio_scsi_ctrl_tmf_resp); 1156 + vc.lunp = &v_req.tmf.lun[0]; 1157 + vc.target = &v_req.tmf.lun[1]; 1158 + break; 1159 + case VIRTIO_SCSI_T_AN_QUERY: 1160 + case VIRTIO_SCSI_T_AN_SUBSCRIBE: 1161 + vc.req = &v_req.an; 1162 + vc.req_size = sizeof(struct virtio_scsi_ctrl_an_req); 1163 + vc.rsp_size = sizeof(struct virtio_scsi_ctrl_an_resp); 1164 + vc.lunp = &v_req.an.lun[0]; 1165 + vc.target = NULL; 1166 + break; 1167 + default: 1168 + vq_err(vq, "Unknown control request %d", v_req.type); 1169 + continue; 1170 + } 1171 + 1172 + /* 1173 + * Validate the size of request and response buffers. 1174 + * Check for a sane response buffer so we can report 1175 + * early errors back to the guest. 1176 + */ 1177 + ret = vhost_scsi_chk_size(vq, &vc); 1178 + if (ret) 1179 + goto err; 1180 + 1181 + /* 1182 + * Get the rest of the request now that its size is known. 1183 + */ 1184 + vc.req += typ_size; 1185 + vc.req_size -= typ_size; 1186 + 1187 + ret = vhost_scsi_get_req(vq, &vc, NULL); 1188 + if (ret) 1189 + goto err; 1190 + 1191 + if (v_req.type == VIRTIO_SCSI_T_TMF) 1192 + vhost_scsi_send_tmf_reject(vs, vq, &vc); 1193 + else 1194 + vhost_scsi_send_an_resp(vs, vq, &vc); 1195 + err: 1196 + /* 1197 + * ENXIO: No more requests, or read error, wait for next kick 1198 + * EINVAL: Invalid response buffer, drop the request 1199 + * EIO: Respond with bad target 1200 + * EAGAIN: Pending request 1201 + */ 1202 + if (ret == -ENXIO) 1203 + break; 1204 + else if (ret == -EIO) 1205 + vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out); 1113 1206 } 1114 1207 out: 1115 1208 mutex_unlock(&vq->mutex); ··· 1277 1050 1278 1051 static void vhost_scsi_ctl_handle_kick(struct vhost_work *work) 1279 1052 { 1053 + struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, 1054 + poll.work); 1055 + struct vhost_scsi *vs = container_of(vq->dev, struct vhost_scsi, dev); 1056 + 1280 1057 pr_debug("%s: The handling func for control queue.\n", __func__); 1058 + vhost_scsi_ctl_handle_vq(vs, vq); 1281 1059 } 1282 1060 1283 1061 static void
+344 -36
drivers/virtio/virtio_balloon.c
··· 41 41 #define VIRTIO_BALLOON_ARRAY_PFNS_MAX 256 42 42 #define VIRTBALLOON_OOM_NOTIFY_PRIORITY 80 43 43 44 + #define VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG (__GFP_NORETRY | __GFP_NOWARN | \ 45 + __GFP_NOMEMALLOC) 46 + /* The order of free page blocks to report to host */ 47 + #define VIRTIO_BALLOON_FREE_PAGE_ORDER (MAX_ORDER - 1) 48 + /* The size of a free page block in bytes */ 49 + #define VIRTIO_BALLOON_FREE_PAGE_SIZE \ 50 + (1 << (VIRTIO_BALLOON_FREE_PAGE_ORDER + PAGE_SHIFT)) 51 + 44 52 #ifdef CONFIG_BALLOON_COMPACTION 45 53 static struct vfsmount *balloon_mnt; 46 54 #endif 47 55 56 + enum virtio_balloon_vq { 57 + VIRTIO_BALLOON_VQ_INFLATE, 58 + VIRTIO_BALLOON_VQ_DEFLATE, 59 + VIRTIO_BALLOON_VQ_STATS, 60 + VIRTIO_BALLOON_VQ_FREE_PAGE, 61 + VIRTIO_BALLOON_VQ_MAX 62 + }; 63 + 48 64 struct virtio_balloon { 49 65 struct virtio_device *vdev; 50 - struct virtqueue *inflate_vq, *deflate_vq, *stats_vq; 66 + struct virtqueue *inflate_vq, *deflate_vq, *stats_vq, *free_page_vq; 67 + 68 + /* Balloon's own wq for cpu-intensive work items */ 69 + struct workqueue_struct *balloon_wq; 70 + /* The free page reporting work item submitted to the balloon wq */ 71 + struct work_struct report_free_page_work; 51 72 52 73 /* The balloon servicing is delegated to a freezable workqueue. */ 53 74 struct work_struct update_balloon_stats_work; ··· 77 56 /* Prevent updating balloon when it is being canceled. */ 78 57 spinlock_t stop_update_lock; 79 58 bool stop_update; 59 + 60 + /* The list of allocated free pages, waiting to be given back to mm */ 61 + struct list_head free_page_list; 62 + spinlock_t free_page_list_lock; 63 + /* The number of free page blocks on the above list */ 64 + unsigned long num_free_page_blocks; 65 + /* The cmd id received from host */ 66 + u32 cmd_id_received; 67 + /* The cmd id that is actively in use */ 68 + __virtio32 cmd_id_active; 69 + /* Buffer to store the stop sign */ 70 + __virtio32 cmd_id_stop; 80 71 81 72 /* Waiting for host to ack the pages we released. */ 82 73 wait_queue_head_t acked; ··· 353 320 virtqueue_kick(vq); 354 321 } 355 322 356 - static void virtballoon_changed(struct virtio_device *vdev) 357 - { 358 - struct virtio_balloon *vb = vdev->priv; 359 - unsigned long flags; 360 - 361 - spin_lock_irqsave(&vb->stop_update_lock, flags); 362 - if (!vb->stop_update) 363 - queue_work(system_freezable_wq, &vb->update_balloon_size_work); 364 - spin_unlock_irqrestore(&vb->stop_update_lock, flags); 365 - } 366 - 367 323 static inline s64 towards_target(struct virtio_balloon *vb) 368 324 { 369 325 s64 target; ··· 367 345 368 346 target = num_pages; 369 347 return target - vb->num_pages; 348 + } 349 + 350 + /* Gives back @num_to_return blocks of free pages to mm. */ 351 + static unsigned long return_free_pages_to_mm(struct virtio_balloon *vb, 352 + unsigned long num_to_return) 353 + { 354 + struct page *page; 355 + unsigned long num_returned; 356 + 357 + spin_lock_irq(&vb->free_page_list_lock); 358 + for (num_returned = 0; num_returned < num_to_return; num_returned++) { 359 + page = balloon_page_pop(&vb->free_page_list); 360 + if (!page) 361 + break; 362 + free_pages((unsigned long)page_address(page), 363 + VIRTIO_BALLOON_FREE_PAGE_ORDER); 364 + } 365 + vb->num_free_page_blocks -= num_returned; 366 + spin_unlock_irq(&vb->free_page_list_lock); 367 + 368 + return num_returned; 369 + } 370 + 371 + static void virtballoon_changed(struct virtio_device *vdev) 372 + { 373 + struct virtio_balloon *vb = vdev->priv; 374 + unsigned long flags; 375 + s64 diff = towards_target(vb); 376 + 377 + if (diff) { 378 + spin_lock_irqsave(&vb->stop_update_lock, flags); 379 + if (!vb->stop_update) 380 + queue_work(system_freezable_wq, 381 + &vb->update_balloon_size_work); 382 + spin_unlock_irqrestore(&vb->stop_update_lock, flags); 383 + } 384 + 385 + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { 386 + virtio_cread(vdev, struct virtio_balloon_config, 387 + free_page_report_cmd_id, &vb->cmd_id_received); 388 + if (vb->cmd_id_received == VIRTIO_BALLOON_CMD_ID_DONE) { 389 + /* Pass ULONG_MAX to give back all the free pages */ 390 + return_free_pages_to_mm(vb, ULONG_MAX); 391 + } else if (vb->cmd_id_received != VIRTIO_BALLOON_CMD_ID_STOP && 392 + vb->cmd_id_received != 393 + virtio32_to_cpu(vdev, vb->cmd_id_active)) { 394 + spin_lock_irqsave(&vb->stop_update_lock, flags); 395 + if (!vb->stop_update) { 396 + queue_work(vb->balloon_wq, 397 + &vb->report_free_page_work); 398 + } 399 + spin_unlock_irqrestore(&vb->stop_update_lock, flags); 400 + } 401 + } 370 402 } 371 403 372 404 static void update_balloon_size(struct virtio_balloon *vb) ··· 465 389 466 390 static int init_vqs(struct virtio_balloon *vb) 467 391 { 468 - struct virtqueue *vqs[3]; 469 - vq_callback_t *callbacks[] = { balloon_ack, balloon_ack, stats_request }; 470 - static const char * const names[] = { "inflate", "deflate", "stats" }; 471 - int err, nvqs; 392 + struct virtqueue *vqs[VIRTIO_BALLOON_VQ_MAX]; 393 + vq_callback_t *callbacks[VIRTIO_BALLOON_VQ_MAX]; 394 + const char *names[VIRTIO_BALLOON_VQ_MAX]; 395 + int err; 472 396 473 397 /* 474 - * We expect two virtqueues: inflate and deflate, and 475 - * optionally stat. 398 + * Inflateq and deflateq are used unconditionally. The names[] 399 + * will be NULL if the related feature is not enabled, which will 400 + * cause no allocation for the corresponding virtqueue in find_vqs. 476 401 */ 477 - nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2; 478 - err = virtio_find_vqs(vb->vdev, nvqs, vqs, callbacks, names, NULL); 402 + callbacks[VIRTIO_BALLOON_VQ_INFLATE] = balloon_ack; 403 + names[VIRTIO_BALLOON_VQ_INFLATE] = "inflate"; 404 + callbacks[VIRTIO_BALLOON_VQ_DEFLATE] = balloon_ack; 405 + names[VIRTIO_BALLOON_VQ_DEFLATE] = "deflate"; 406 + names[VIRTIO_BALLOON_VQ_STATS] = NULL; 407 + names[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL; 408 + 409 + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { 410 + names[VIRTIO_BALLOON_VQ_STATS] = "stats"; 411 + callbacks[VIRTIO_BALLOON_VQ_STATS] = stats_request; 412 + } 413 + 414 + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { 415 + names[VIRTIO_BALLOON_VQ_FREE_PAGE] = "free_page_vq"; 416 + callbacks[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL; 417 + } 418 + 419 + err = vb->vdev->config->find_vqs(vb->vdev, VIRTIO_BALLOON_VQ_MAX, 420 + vqs, callbacks, names, NULL, NULL); 479 421 if (err) 480 422 return err; 481 423 482 - vb->inflate_vq = vqs[0]; 483 - vb->deflate_vq = vqs[1]; 424 + vb->inflate_vq = vqs[VIRTIO_BALLOON_VQ_INFLATE]; 425 + vb->deflate_vq = vqs[VIRTIO_BALLOON_VQ_DEFLATE]; 484 426 if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { 485 427 struct scatterlist sg; 486 428 unsigned int num_stats; 487 - vb->stats_vq = vqs[2]; 429 + vb->stats_vq = vqs[VIRTIO_BALLOON_VQ_STATS]; 488 430 489 431 /* 490 432 * Prime this virtqueue with one buffer so the hypervisor can ··· 520 426 } 521 427 virtqueue_kick(vb->stats_vq); 522 428 } 429 + 430 + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) 431 + vb->free_page_vq = vqs[VIRTIO_BALLOON_VQ_FREE_PAGE]; 432 + 523 433 return 0; 434 + } 435 + 436 + static int send_cmd_id_start(struct virtio_balloon *vb) 437 + { 438 + struct scatterlist sg; 439 + struct virtqueue *vq = vb->free_page_vq; 440 + int err, unused; 441 + 442 + /* Detach all the used buffers from the vq */ 443 + while (virtqueue_get_buf(vq, &unused)) 444 + ; 445 + 446 + vb->cmd_id_active = cpu_to_virtio32(vb->vdev, vb->cmd_id_received); 447 + sg_init_one(&sg, &vb->cmd_id_active, sizeof(vb->cmd_id_active)); 448 + err = virtqueue_add_outbuf(vq, &sg, 1, &vb->cmd_id_active, GFP_KERNEL); 449 + if (!err) 450 + virtqueue_kick(vq); 451 + return err; 452 + } 453 + 454 + static int send_cmd_id_stop(struct virtio_balloon *vb) 455 + { 456 + struct scatterlist sg; 457 + struct virtqueue *vq = vb->free_page_vq; 458 + int err, unused; 459 + 460 + /* Detach all the used buffers from the vq */ 461 + while (virtqueue_get_buf(vq, &unused)) 462 + ; 463 + 464 + sg_init_one(&sg, &vb->cmd_id_stop, sizeof(vb->cmd_id_stop)); 465 + err = virtqueue_add_outbuf(vq, &sg, 1, &vb->cmd_id_stop, GFP_KERNEL); 466 + if (!err) 467 + virtqueue_kick(vq); 468 + return err; 469 + } 470 + 471 + static int get_free_page_and_send(struct virtio_balloon *vb) 472 + { 473 + struct virtqueue *vq = vb->free_page_vq; 474 + struct page *page; 475 + struct scatterlist sg; 476 + int err, unused; 477 + void *p; 478 + 479 + /* Detach all the used buffers from the vq */ 480 + while (virtqueue_get_buf(vq, &unused)) 481 + ; 482 + 483 + page = alloc_pages(VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG, 484 + VIRTIO_BALLOON_FREE_PAGE_ORDER); 485 + /* 486 + * When the allocation returns NULL, it indicates that we have got all 487 + * the possible free pages, so return -EINTR to stop. 488 + */ 489 + if (!page) 490 + return -EINTR; 491 + 492 + p = page_address(page); 493 + sg_init_one(&sg, p, VIRTIO_BALLOON_FREE_PAGE_SIZE); 494 + /* There is always 1 entry reserved for the cmd id to use. */ 495 + if (vq->num_free > 1) { 496 + err = virtqueue_add_inbuf(vq, &sg, 1, p, GFP_KERNEL); 497 + if (unlikely(err)) { 498 + free_pages((unsigned long)p, 499 + VIRTIO_BALLOON_FREE_PAGE_ORDER); 500 + return err; 501 + } 502 + virtqueue_kick(vq); 503 + spin_lock_irq(&vb->free_page_list_lock); 504 + balloon_page_push(&vb->free_page_list, page); 505 + vb->num_free_page_blocks++; 506 + spin_unlock_irq(&vb->free_page_list_lock); 507 + } else { 508 + /* 509 + * The vq has no available entry to add this page block, so 510 + * just free it. 511 + */ 512 + free_pages((unsigned long)p, VIRTIO_BALLOON_FREE_PAGE_ORDER); 513 + } 514 + 515 + return 0; 516 + } 517 + 518 + static int send_free_pages(struct virtio_balloon *vb) 519 + { 520 + int err; 521 + u32 cmd_id_active; 522 + 523 + while (1) { 524 + /* 525 + * If a stop id or a new cmd id was just received from host, 526 + * stop the reporting. 527 + */ 528 + cmd_id_active = virtio32_to_cpu(vb->vdev, vb->cmd_id_active); 529 + if (cmd_id_active != vb->cmd_id_received) 530 + break; 531 + 532 + /* 533 + * The free page blocks are allocated and sent to host one by 534 + * one. 535 + */ 536 + err = get_free_page_and_send(vb); 537 + if (err == -EINTR) 538 + break; 539 + else if (unlikely(err)) 540 + return err; 541 + } 542 + 543 + return 0; 544 + } 545 + 546 + static void report_free_page_func(struct work_struct *work) 547 + { 548 + int err; 549 + struct virtio_balloon *vb = container_of(work, struct virtio_balloon, 550 + report_free_page_work); 551 + struct device *dev = &vb->vdev->dev; 552 + 553 + /* Start by sending the received cmd id to host with an outbuf. */ 554 + err = send_cmd_id_start(vb); 555 + if (unlikely(err)) 556 + dev_err(dev, "Failed to send a start id, err = %d\n", err); 557 + 558 + err = send_free_pages(vb); 559 + if (unlikely(err)) 560 + dev_err(dev, "Failed to send a free page, err = %d\n", err); 561 + 562 + /* End by sending a stop id to host with an outbuf. */ 563 + err = send_cmd_id_stop(vb); 564 + if (unlikely(err)) 565 + dev_err(dev, "Failed to send a stop id, err = %d\n", err); 524 566 } 525 567 526 568 #ifdef CONFIG_BALLOON_COMPACTION ··· 742 512 743 513 #endif /* CONFIG_BALLOON_COMPACTION */ 744 514 515 + static unsigned long shrink_free_pages(struct virtio_balloon *vb, 516 + unsigned long pages_to_free) 517 + { 518 + unsigned long blocks_to_free, blocks_freed; 519 + 520 + pages_to_free = round_up(pages_to_free, 521 + 1 << VIRTIO_BALLOON_FREE_PAGE_ORDER); 522 + blocks_to_free = pages_to_free >> VIRTIO_BALLOON_FREE_PAGE_ORDER; 523 + blocks_freed = return_free_pages_to_mm(vb, blocks_to_free); 524 + 525 + return blocks_freed << VIRTIO_BALLOON_FREE_PAGE_ORDER; 526 + } 527 + 528 + static unsigned long shrink_balloon_pages(struct virtio_balloon *vb, 529 + unsigned long pages_to_free) 530 + { 531 + unsigned long pages_freed = 0; 532 + 533 + /* 534 + * One invocation of leak_balloon can deflate at most 535 + * VIRTIO_BALLOON_ARRAY_PFNS_MAX balloon pages, so we call it 536 + * multiple times to deflate pages till reaching pages_to_free. 537 + */ 538 + while (vb->num_pages && pages_to_free) { 539 + pages_freed += leak_balloon(vb, pages_to_free) / 540 + VIRTIO_BALLOON_PAGES_PER_PAGE; 541 + pages_to_free -= pages_freed; 542 + } 543 + update_balloon_size(vb); 544 + 545 + return pages_freed; 546 + } 547 + 745 548 static unsigned long virtio_balloon_shrinker_scan(struct shrinker *shrinker, 746 549 struct shrink_control *sc) 747 550 { ··· 784 521 785 522 pages_to_free = sc->nr_to_scan * VIRTIO_BALLOON_PAGES_PER_PAGE; 786 523 787 - /* 788 - * One invocation of leak_balloon can deflate at most 789 - * VIRTIO_BALLOON_ARRAY_PFNS_MAX balloon pages, so we call it 790 - * multiple times to deflate pages till reaching pages_to_free. 791 - */ 792 - while (vb->num_pages && pages_to_free) { 793 - pages_to_free -= pages_freed; 794 - pages_freed += leak_balloon(vb, pages_to_free); 795 - } 796 - update_balloon_size(vb); 524 + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) 525 + pages_freed = shrink_free_pages(vb, pages_to_free); 797 526 798 - return pages_freed / VIRTIO_BALLOON_PAGES_PER_PAGE; 527 + if (pages_freed >= pages_to_free) 528 + return pages_freed; 529 + 530 + pages_freed += shrink_balloon_pages(vb, pages_to_free - pages_freed); 531 + 532 + return pages_freed; 799 533 } 800 534 801 535 static unsigned long virtio_balloon_shrinker_count(struct shrinker *shrinker, ··· 800 540 { 801 541 struct virtio_balloon *vb = container_of(shrinker, 802 542 struct virtio_balloon, shrinker); 543 + unsigned long count; 803 544 804 - return vb->num_pages / VIRTIO_BALLOON_PAGES_PER_PAGE; 545 + count = vb->num_pages / VIRTIO_BALLOON_PAGES_PER_PAGE; 546 + count += vb->num_free_page_blocks >> VIRTIO_BALLOON_FREE_PAGE_ORDER; 547 + 548 + return count; 805 549 } 806 550 807 551 static void virtio_balloon_unregister_shrinker(struct virtio_balloon *vb) ··· 825 561 static int virtballoon_probe(struct virtio_device *vdev) 826 562 { 827 563 struct virtio_balloon *vb; 564 + __u32 poison_val; 828 565 int err; 829 566 830 567 if (!vdev->config->get) { ··· 869 604 } 870 605 vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops; 871 606 #endif 607 + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { 608 + /* 609 + * There is always one entry reserved for cmd id, so the ring 610 + * size needs to be at least two to report free page hints. 611 + */ 612 + if (virtqueue_get_vring_size(vb->free_page_vq) < 2) { 613 + err = -ENOSPC; 614 + goto out_del_vqs; 615 + } 616 + vb->balloon_wq = alloc_workqueue("balloon-wq", 617 + WQ_FREEZABLE | WQ_CPU_INTENSIVE, 0); 618 + if (!vb->balloon_wq) { 619 + err = -ENOMEM; 620 + goto out_del_vqs; 621 + } 622 + INIT_WORK(&vb->report_free_page_work, report_free_page_func); 623 + vb->cmd_id_received = VIRTIO_BALLOON_CMD_ID_STOP; 624 + vb->cmd_id_active = cpu_to_virtio32(vb->vdev, 625 + VIRTIO_BALLOON_CMD_ID_STOP); 626 + vb->cmd_id_stop = cpu_to_virtio32(vb->vdev, 627 + VIRTIO_BALLOON_CMD_ID_STOP); 628 + vb->num_free_page_blocks = 0; 629 + spin_lock_init(&vb->free_page_list_lock); 630 + INIT_LIST_HEAD(&vb->free_page_list); 631 + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) { 632 + memset(&poison_val, PAGE_POISON, sizeof(poison_val)); 633 + virtio_cwrite(vb->vdev, struct virtio_balloon_config, 634 + poison_val, &poison_val); 635 + } 636 + } 872 637 /* 873 638 * We continue to use VIRTIO_BALLOON_F_DEFLATE_ON_OOM to decide if a 874 639 * shrinker needs to be registered to relieve memory pressure. ··· 906 611 if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) { 907 612 err = virtio_balloon_register_shrinker(vb); 908 613 if (err) 909 - goto out_del_vqs; 614 + goto out_del_balloon_wq; 910 615 } 911 616 virtio_device_ready(vdev); 912 617 ··· 914 619 virtballoon_changed(vdev); 915 620 return 0; 916 621 622 + out_del_balloon_wq: 623 + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) 624 + destroy_workqueue(vb->balloon_wq); 917 625 out_del_vqs: 918 626 vdev->config->del_vqs(vdev); 919 627 out_free_vb: ··· 949 651 spin_unlock_irq(&vb->stop_update_lock); 950 652 cancel_work_sync(&vb->update_balloon_size_work); 951 653 cancel_work_sync(&vb->update_balloon_stats_work); 654 + 655 + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { 656 + cancel_work_sync(&vb->report_free_page_work); 657 + destroy_workqueue(vb->balloon_wq); 658 + } 952 659 953 660 remove_common(vb); 954 661 #ifdef CONFIG_BALLOON_COMPACTION ··· 998 695 999 696 static int virtballoon_validate(struct virtio_device *vdev) 1000 697 { 698 + if (!page_poisoning_enabled()) 699 + __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_PAGE_POISON); 700 + 1001 701 __virtio_clear_bit(vdev, VIRTIO_F_IOMMU_PLATFORM); 1002 702 return 0; 1003 703 } ··· 1009 703 VIRTIO_BALLOON_F_MUST_TELL_HOST, 1010 704 VIRTIO_BALLOON_F_STATS_VQ, 1011 705 VIRTIO_BALLOON_F_DEFLATE_ON_OOM, 706 + VIRTIO_BALLOON_F_FREE_PAGE_HINT, 707 + VIRTIO_BALLOON_F_PAGE_POISON, 1012 708 }; 1013 709 1014 710 static struct virtio_driver virtio_balloon_driver = {
+8
include/uapi/linux/virtio_balloon.h
··· 34 34 #define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */ 35 35 #define VIRTIO_BALLOON_F_STATS_VQ 1 /* Memory Stats virtqueue */ 36 36 #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */ 37 + #define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3 /* VQ to report free pages */ 38 + #define VIRTIO_BALLOON_F_PAGE_POISON 4 /* Guest is using page poisoning */ 37 39 38 40 /* Size of a PFN in the balloon interface. */ 39 41 #define VIRTIO_BALLOON_PFN_SHIFT 12 40 42 43 + #define VIRTIO_BALLOON_CMD_ID_STOP 0 44 + #define VIRTIO_BALLOON_CMD_ID_DONE 1 41 45 struct virtio_balloon_config { 42 46 /* Number of pages host wants Guest to give up. */ 43 47 __u32 num_pages; 44 48 /* Number of pages we've actually got in balloon. */ 45 49 __u32 actual; 50 + /* Free page report command id, readonly by guest */ 51 + __u32 free_page_report_cmd_id; 52 + /* Stores PAGE_POISON if page poisoning is in use */ 53 + __u32 poison_val; 46 54 }; 47 55 48 56 #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */
+1
kernel/configs/kvm_guest.config
··· 20 20 CONFIG_KVM_GUEST=y 21 21 CONFIG_S390_GUEST=y 22 22 CONFIG_VIRTIO=y 23 + CONFIG_VIRTIO_MENU=y 23 24 CONFIG_VIRTIO_PCI=y 24 25 CONFIG_VIRTIO_BLK=y 25 26 CONFIG_VIRTIO_CONSOLE=y
+6
mm/page_poison.c
··· 17 17 } 18 18 early_param("page_poison", early_page_poison_param); 19 19 20 + /** 21 + * page_poisoning_enabled - check if page poisoning is enabled 22 + * 23 + * Return true if page poisoning is enabled, or false if not. 24 + */ 20 25 bool page_poisoning_enabled(void) 21 26 { 22 27 /* ··· 34 29 (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && 35 30 debug_pagealloc_enabled())); 36 31 } 32 + EXPORT_SYMBOL_GPL(page_poisoning_enabled); 37 33 38 34 static void poison_page(struct page *page) 39 35 {