mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
Compare commits
38 Commits
ccd1cdca5c
...
04688d6128
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04688d6128 | ||
|
|
1e5e062ad8 | ||
|
|
b63f4a4e95 | ||
|
|
3f0e9c8cef | ||
|
|
4079a38693 | ||
|
|
8f0cbedc86 | ||
|
|
e2cc644089 | ||
|
|
b14fad5553 | ||
|
|
cfe54f4591 | ||
|
|
61ed08c2fd | ||
|
|
5688e977ed | ||
|
|
cb6d5aa9c0 | ||
|
|
d8ee3cfdc8 | ||
|
|
7f81878b04 | ||
|
|
39cfe193f3 | ||
|
|
e88dfb9331 | ||
|
|
cec9c5e385 | ||
|
|
b0fe545b3c | ||
|
|
a2f964c45b | ||
|
|
4e949e77fa | ||
|
|
b6600eff05 | ||
|
|
c53ad75c62 | ||
|
|
03d768a38c | ||
|
|
42059e68ea | ||
|
|
16fe720f1d | ||
|
|
f059588c55 | ||
|
|
94fb5e796a | ||
|
|
2b74209458 | ||
|
|
87e7f60190 | ||
|
|
4c7d8eb9a7 | ||
|
|
3b9c30eb8f | ||
|
|
0b444cfd8b | ||
|
|
0a70cac789 | ||
|
|
1ddb815fdf | ||
|
|
daa24603d9 | ||
|
|
d412ff9e26 | ||
|
|
e2f1081ca8 | ||
|
|
d8932355f8 |
@ -112,7 +112,7 @@ struct rnbd_clt_dev {
|
||||
struct rnbd_queue *hw_queues;
|
||||
u32 device_id;
|
||||
/* local Idr index - used to track minor number allocations. */
|
||||
u32 clt_device_id;
|
||||
int clt_device_id;
|
||||
struct mutex lock;
|
||||
enum rnbd_clt_dev_state dev_state;
|
||||
refcount_t refcount;
|
||||
|
||||
@ -1607,8 +1607,7 @@ static bool ublk_check_and_reset_active_ref(struct ublk_device *ub)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (!(ub->dev_info.flags & (UBLK_F_SUPPORT_ZERO_COPY |
|
||||
UBLK_F_AUTO_BUF_REG)))
|
||||
if (!ublk_dev_need_req_ref(ub))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < ub->dev_info.nr_hw_queues; i++) {
|
||||
|
||||
@ -73,6 +73,7 @@ struct mm_struct efi_mm = {
|
||||
MMAP_LOCK_INITIALIZER(efi_mm)
|
||||
.page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock),
|
||||
.mmlist = LIST_HEAD_INIT(efi_mm.mmlist),
|
||||
.user_ns = &init_user_ns,
|
||||
.cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0},
|
||||
#ifdef CONFIG_SCHED_MM_CID
|
||||
.mm_cid.lock = __RAW_SPIN_LOCK_UNLOCKED(efi_mm.mm_cid.lock),
|
||||
|
||||
@ -513,15 +513,15 @@ efi_status_t efi_setup_graphics(struct screen_info *si, struct edid_info *edid)
|
||||
status = efi_bs_call(handle_protocol, handle, &EFI_EDID_ACTIVE_PROTOCOL_GUID,
|
||||
(void **)&active_edid);
|
||||
if (status == EFI_SUCCESS) {
|
||||
gop_size_of_edid = active_edid->size_of_edid;
|
||||
gop_edid = active_edid->edid;
|
||||
gop_size_of_edid = efi_table_attr(active_edid, size_of_edid);
|
||||
gop_edid = efi_table_attr(active_edid, edid);
|
||||
} else {
|
||||
status = efi_bs_call(handle_protocol, handle,
|
||||
&EFI_EDID_DISCOVERED_PROTOCOL_GUID,
|
||||
(void **)&discovered_edid);
|
||||
if (status == EFI_SUCCESS) {
|
||||
gop_size_of_edid = discovered_edid->size_of_edid;
|
||||
gop_edid = discovered_edid->edid;
|
||||
gop_size_of_edid = efi_table_attr(discovered_edid, size_of_edid);
|
||||
gop_edid = efi_table_attr(discovered_edid, edid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -66,14 +66,15 @@ static u32 vhost_transport_get_local_cid(void)
|
||||
return VHOST_VSOCK_DEFAULT_HOST_CID;
|
||||
}
|
||||
|
||||
/* Callers that dereference the return value must hold vhost_vsock_mutex or the
|
||||
* RCU read lock.
|
||||
/* Callers must be in an RCU read section or hold the vhost_vsock_mutex.
|
||||
* The return value can only be dereferenced while within the section.
|
||||
*/
|
||||
static struct vhost_vsock *vhost_vsock_get(u32 guest_cid)
|
||||
{
|
||||
struct vhost_vsock *vsock;
|
||||
|
||||
hash_for_each_possible_rcu(vhost_vsock_hash, vsock, hash, guest_cid) {
|
||||
hash_for_each_possible_rcu(vhost_vsock_hash, vsock, hash, guest_cid,
|
||||
lockdep_is_held(&vhost_vsock_mutex)) {
|
||||
u32 other_cid = vsock->guest_cid;
|
||||
|
||||
/* Skip instances that have no CID yet */
|
||||
@ -709,9 +710,15 @@ static void vhost_vsock_reset_orphans(struct sock *sk)
|
||||
* executing.
|
||||
*/
|
||||
|
||||
rcu_read_lock();
|
||||
|
||||
/* If the peer is still valid, no need to reset connection */
|
||||
if (vhost_vsock_get(vsk->remote_addr.svm_cid))
|
||||
if (vhost_vsock_get(vsk->remote_addr.svm_cid)) {
|
||||
rcu_read_unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
/* If the close timeout is pending, let it expire. This avoids races
|
||||
* with the timeout callback.
|
||||
|
||||
@ -841,8 +841,10 @@ int __printf(2, 3) debugfs_change_name(struct dentry *dentry, const char *fmt, .
|
||||
rd.new_parent = rd.old_parent;
|
||||
rd.flags = RENAME_NOREPLACE;
|
||||
target = lookup_noperm_unlocked(&QSTR(new_name), rd.new_parent);
|
||||
if (IS_ERR(target))
|
||||
return PTR_ERR(target);
|
||||
if (IS_ERR(target)) {
|
||||
error = PTR_ERR(target);
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
error = start_renaming_two_dentries(&rd, dentry, target);
|
||||
if (error) {
|
||||
@ -862,6 +864,7 @@ int __printf(2, 3) debugfs_change_name(struct dentry *dentry, const char *fmt, .
|
||||
out:
|
||||
dput(rd.old_parent);
|
||||
dput(target);
|
||||
out_free:
|
||||
kfree_const(new_name);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -681,8 +681,10 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
|
||||
return kn;
|
||||
|
||||
err_out4:
|
||||
simple_xattrs_free(&kn->iattr->xattrs, NULL);
|
||||
kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
|
||||
if (kn->iattr) {
|
||||
simple_xattrs_free(&kn->iattr->xattrs, NULL);
|
||||
kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
|
||||
}
|
||||
err_out3:
|
||||
spin_lock(&root->kernfs_idr_lock);
|
||||
idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));
|
||||
|
||||
@ -1139,6 +1139,8 @@ static int smb3_reconfigure(struct fs_context *fc)
|
||||
rc = smb3_sync_session_ctx_passwords(cifs_sb, ses);
|
||||
if (rc) {
|
||||
mutex_unlock(&ses->session_mutex);
|
||||
kfree_sensitive(new_password);
|
||||
kfree_sensitive(new_password2);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -714,7 +714,7 @@ void ksmbd_gen_smb311_encryptionkey(struct ksmbd_conn *conn,
|
||||
int ksmbd_gen_preauth_integrity_hash(struct ksmbd_conn *conn, char *buf,
|
||||
__u8 *pi_hash)
|
||||
{
|
||||
struct smb2_hdr *rcv_hdr = smb2_get_msg(buf);
|
||||
struct smb2_hdr *rcv_hdr = smb_get_msg(buf);
|
||||
char *all_bytes_msg = (char *)&rcv_hdr->ProtocolId;
|
||||
int msg_size = get_rfc1002_len(buf);
|
||||
struct sha512_ctx sha_ctx;
|
||||
@ -841,7 +841,7 @@ int ksmbd_crypt_message(struct ksmbd_work *work, struct kvec *iov,
|
||||
unsigned int nvec, int enc)
|
||||
{
|
||||
struct ksmbd_conn *conn = work->conn;
|
||||
struct smb2_transform_hdr *tr_hdr = smb2_get_msg(iov[0].iov_base);
|
||||
struct smb2_transform_hdr *tr_hdr = smb_get_msg(iov[0].iov_base);
|
||||
unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20;
|
||||
int rc;
|
||||
struct scatterlist *sg;
|
||||
|
||||
@ -295,8 +295,9 @@ bool ksmbd_conn_alive(struct ksmbd_conn *conn)
|
||||
return true;
|
||||
}
|
||||
|
||||
#define SMB1_MIN_SUPPORTED_HEADER_SIZE (sizeof(struct smb_hdr))
|
||||
#define SMB2_MIN_SUPPORTED_HEADER_SIZE (sizeof(struct smb2_hdr) + 4)
|
||||
/* "+2" for BCC field (ByteCount, 2 bytes) */
|
||||
#define SMB1_MIN_SUPPORTED_PDU_SIZE (sizeof(struct smb_hdr) + 2)
|
||||
#define SMB2_MIN_SUPPORTED_PDU_SIZE (sizeof(struct smb2_pdu))
|
||||
|
||||
/**
|
||||
* ksmbd_conn_handler_loop() - session thread to listen on new smb requests
|
||||
@ -363,7 +364,7 @@ recheck:
|
||||
if (pdu_size > MAX_STREAM_PROT_LEN)
|
||||
break;
|
||||
|
||||
if (pdu_size < SMB1_MIN_SUPPORTED_HEADER_SIZE)
|
||||
if (pdu_size < SMB1_MIN_SUPPORTED_PDU_SIZE)
|
||||
break;
|
||||
|
||||
/* 4 for rfc1002 length field */
|
||||
@ -394,9 +395,9 @@ recheck:
|
||||
if (!ksmbd_smb_request(conn))
|
||||
break;
|
||||
|
||||
if (((struct smb2_hdr *)smb2_get_msg(conn->request_buf))->ProtocolId ==
|
||||
if (((struct smb2_hdr *)smb_get_msg(conn->request_buf))->ProtocolId ==
|
||||
SMB2_PROTO_NUMBER) {
|
||||
if (pdu_size < SMB2_MIN_SUPPORTED_HEADER_SIZE)
|
||||
if (pdu_size < SMB2_MIN_SUPPORTED_PDU_SIZE)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -637,7 +637,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
|
||||
goto out;
|
||||
}
|
||||
|
||||
rsp_hdr = smb2_get_msg(work->response_buf);
|
||||
rsp_hdr = smb_get_msg(work->response_buf);
|
||||
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
|
||||
rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
|
||||
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
|
||||
@ -651,7 +651,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
|
||||
rsp_hdr->SessionId = 0;
|
||||
memset(rsp_hdr->Signature, 0, 16);
|
||||
|
||||
rsp = smb2_get_msg(work->response_buf);
|
||||
rsp = smb_get_msg(work->response_buf);
|
||||
|
||||
rsp->StructureSize = cpu_to_le16(24);
|
||||
if (!br_info->open_trunc &&
|
||||
@ -744,7 +744,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
|
||||
goto out;
|
||||
}
|
||||
|
||||
rsp_hdr = smb2_get_msg(work->response_buf);
|
||||
rsp_hdr = smb_get_msg(work->response_buf);
|
||||
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
|
||||
rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
|
||||
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
|
||||
@ -758,7 +758,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
|
||||
rsp_hdr->SessionId = 0;
|
||||
memset(rsp_hdr->Signature, 0, 16);
|
||||
|
||||
rsp = smb2_get_msg(work->response_buf);
|
||||
rsp = smb_get_msg(work->response_buf);
|
||||
rsp->StructureSize = cpu_to_le16(44);
|
||||
rsp->Epoch = br_info->epoch;
|
||||
rsp->Flags = 0;
|
||||
|
||||
@ -95,7 +95,7 @@ static inline int check_conn_state(struct ksmbd_work *work)
|
||||
|
||||
if (ksmbd_conn_exiting(work->conn) ||
|
||||
ksmbd_conn_need_reconnect(work->conn)) {
|
||||
rsp_hdr = work->response_buf;
|
||||
rsp_hdr = smb_get_msg(work->response_buf);
|
||||
rsp_hdr->Status.CifsError = STATUS_CONNECTION_DISCONNECTED;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ static void __wbuf(struct ksmbd_work *work, void **req, void **rsp)
|
||||
*req = ksmbd_req_buf_next(work);
|
||||
*rsp = ksmbd_resp_buf_next(work);
|
||||
} else {
|
||||
*req = smb2_get_msg(work->request_buf);
|
||||
*rsp = smb2_get_msg(work->response_buf);
|
||||
*req = smb_get_msg(work->request_buf);
|
||||
*rsp = smb_get_msg(work->response_buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ void smb2_set_err_rsp(struct ksmbd_work *work)
|
||||
if (work->next_smb2_rcv_hdr_off)
|
||||
err_rsp = ksmbd_resp_buf_next(work);
|
||||
else
|
||||
err_rsp = smb2_get_msg(work->response_buf);
|
||||
err_rsp = smb_get_msg(work->response_buf);
|
||||
|
||||
if (err_rsp->hdr.Status != STATUS_STOPPED_ON_SYMLINK) {
|
||||
int err;
|
||||
@ -172,7 +172,7 @@ void smb2_set_err_rsp(struct ksmbd_work *work)
|
||||
*/
|
||||
bool is_smb2_neg_cmd(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb2_hdr *hdr = smb2_get_msg(work->request_buf);
|
||||
struct smb2_hdr *hdr = smb_get_msg(work->request_buf);
|
||||
|
||||
/* is it SMB2 header ? */
|
||||
if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
|
||||
@ -196,7 +196,7 @@ bool is_smb2_neg_cmd(struct ksmbd_work *work)
|
||||
*/
|
||||
bool is_smb2_rsp(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb2_hdr *hdr = smb2_get_msg(work->response_buf);
|
||||
struct smb2_hdr *hdr = smb_get_msg(work->response_buf);
|
||||
|
||||
/* is it SMB2 header ? */
|
||||
if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
|
||||
@ -222,7 +222,7 @@ u16 get_smb2_cmd_val(struct ksmbd_work *work)
|
||||
if (work->next_smb2_rcv_hdr_off)
|
||||
rcv_hdr = ksmbd_req_buf_next(work);
|
||||
else
|
||||
rcv_hdr = smb2_get_msg(work->request_buf);
|
||||
rcv_hdr = smb_get_msg(work->request_buf);
|
||||
return le16_to_cpu(rcv_hdr->Command);
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ void set_smb2_rsp_status(struct ksmbd_work *work, __le32 err)
|
||||
{
|
||||
struct smb2_hdr *rsp_hdr;
|
||||
|
||||
rsp_hdr = smb2_get_msg(work->response_buf);
|
||||
rsp_hdr = smb_get_msg(work->response_buf);
|
||||
rsp_hdr->Status = err;
|
||||
|
||||
work->iov_idx = 0;
|
||||
@ -258,7 +258,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
|
||||
struct ksmbd_conn *conn = work->conn;
|
||||
int err;
|
||||
|
||||
rsp_hdr = smb2_get_msg(work->response_buf);
|
||||
rsp_hdr = smb_get_msg(work->response_buf);
|
||||
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
|
||||
rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
|
||||
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
|
||||
@ -272,7 +272,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
|
||||
rsp_hdr->SessionId = 0;
|
||||
memset(rsp_hdr->Signature, 0, 16);
|
||||
|
||||
rsp = smb2_get_msg(work->response_buf);
|
||||
rsp = smb_get_msg(work->response_buf);
|
||||
|
||||
WARN_ON(ksmbd_conn_good(conn));
|
||||
|
||||
@ -446,7 +446,7 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work)
|
||||
*/
|
||||
bool is_chained_smb2_message(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb2_hdr *hdr = smb2_get_msg(work->request_buf);
|
||||
struct smb2_hdr *hdr = smb_get_msg(work->request_buf);
|
||||
unsigned int len, next_cmd;
|
||||
|
||||
if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
|
||||
@ -497,8 +497,8 @@ bool is_chained_smb2_message(struct ksmbd_work *work)
|
||||
*/
|
||||
int init_smb2_rsp_hdr(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb2_hdr *rsp_hdr = smb2_get_msg(work->response_buf);
|
||||
struct smb2_hdr *rcv_hdr = smb2_get_msg(work->request_buf);
|
||||
struct smb2_hdr *rsp_hdr = smb_get_msg(work->response_buf);
|
||||
struct smb2_hdr *rcv_hdr = smb_get_msg(work->request_buf);
|
||||
|
||||
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
|
||||
rsp_hdr->ProtocolId = rcv_hdr->ProtocolId;
|
||||
@ -527,7 +527,7 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work)
|
||||
*/
|
||||
int smb2_allocate_rsp_buf(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb2_hdr *hdr = smb2_get_msg(work->request_buf);
|
||||
struct smb2_hdr *hdr = smb_get_msg(work->request_buf);
|
||||
size_t small_sz = MAX_CIFS_SMALL_BUFFER_SIZE;
|
||||
size_t large_sz = small_sz + work->conn->vals->max_trans_size;
|
||||
size_t sz = small_sz;
|
||||
@ -543,7 +543,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
|
||||
offsetof(struct smb2_query_info_req, OutputBufferLength))
|
||||
return -EINVAL;
|
||||
|
||||
req = smb2_get_msg(work->request_buf);
|
||||
req = smb_get_msg(work->request_buf);
|
||||
if ((req->InfoType == SMB2_O_INFO_FILE &&
|
||||
(req->FileInfoClass == FILE_FULL_EA_INFORMATION ||
|
||||
req->FileInfoClass == FILE_ALL_INFORMATION)) ||
|
||||
@ -712,10 +712,10 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
|
||||
}
|
||||
|
||||
in_work->conn = work->conn;
|
||||
memcpy(smb2_get_msg(in_work->response_buf), ksmbd_resp_buf_next(work),
|
||||
memcpy(smb_get_msg(in_work->response_buf), ksmbd_resp_buf_next(work),
|
||||
__SMB2_HEADER_STRUCTURE_SIZE);
|
||||
|
||||
rsp_hdr = smb2_get_msg(in_work->response_buf);
|
||||
rsp_hdr = smb_get_msg(in_work->response_buf);
|
||||
rsp_hdr->Flags |= SMB2_FLAGS_ASYNC_COMMAND;
|
||||
rsp_hdr->Id.AsyncId = cpu_to_le64(work->async_id);
|
||||
smb2_set_err_rsp(in_work);
|
||||
@ -1093,8 +1093,8 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn,
|
||||
int smb2_handle_negotiate(struct ksmbd_work *work)
|
||||
{
|
||||
struct ksmbd_conn *conn = work->conn;
|
||||
struct smb2_negotiate_req *req = smb2_get_msg(work->request_buf);
|
||||
struct smb2_negotiate_rsp *rsp = smb2_get_msg(work->response_buf);
|
||||
struct smb2_negotiate_req *req = smb_get_msg(work->request_buf);
|
||||
struct smb2_negotiate_rsp *rsp = smb_get_msg(work->response_buf);
|
||||
int rc = 0;
|
||||
unsigned int smb2_buf_len, smb2_neg_size, neg_ctxt_len = 0;
|
||||
__le32 status;
|
||||
@ -5967,7 +5967,7 @@ out:
|
||||
*/
|
||||
int smb2_echo(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb2_echo_rsp *rsp = smb2_get_msg(work->response_buf);
|
||||
struct smb2_echo_rsp *rsp = smb_get_msg(work->response_buf);
|
||||
|
||||
ksmbd_debug(SMB, "Received smb2 echo request\n");
|
||||
|
||||
@ -6520,8 +6520,8 @@ int smb2_set_info(struct ksmbd_work *work)
|
||||
pid = work->compound_pfid;
|
||||
}
|
||||
} else {
|
||||
req = smb2_get_msg(work->request_buf);
|
||||
rsp = smb2_get_msg(work->response_buf);
|
||||
req = smb_get_msg(work->request_buf);
|
||||
rsp = smb_get_msg(work->response_buf);
|
||||
}
|
||||
|
||||
if (!test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) {
|
||||
@ -6754,8 +6754,8 @@ int smb2_read(struct ksmbd_work *work)
|
||||
pid = work->compound_pfid;
|
||||
}
|
||||
} else {
|
||||
req = smb2_get_msg(work->request_buf);
|
||||
rsp = smb2_get_msg(work->response_buf);
|
||||
req = smb_get_msg(work->request_buf);
|
||||
rsp = smb_get_msg(work->response_buf);
|
||||
}
|
||||
|
||||
if (!has_file_id(id)) {
|
||||
@ -7183,7 +7183,7 @@ out:
|
||||
int smb2_cancel(struct ksmbd_work *work)
|
||||
{
|
||||
struct ksmbd_conn *conn = work->conn;
|
||||
struct smb2_hdr *hdr = smb2_get_msg(work->request_buf);
|
||||
struct smb2_hdr *hdr = smb_get_msg(work->request_buf);
|
||||
struct smb2_hdr *chdr;
|
||||
struct ksmbd_work *iter;
|
||||
struct list_head *command_list;
|
||||
@ -7200,7 +7200,7 @@ int smb2_cancel(struct ksmbd_work *work)
|
||||
spin_lock(&conn->request_lock);
|
||||
list_for_each_entry(iter, command_list,
|
||||
async_request_entry) {
|
||||
chdr = smb2_get_msg(iter->request_buf);
|
||||
chdr = smb_get_msg(iter->request_buf);
|
||||
|
||||
if (iter->async_id !=
|
||||
le64_to_cpu(hdr->Id.AsyncId))
|
||||
@ -7221,7 +7221,7 @@ int smb2_cancel(struct ksmbd_work *work)
|
||||
|
||||
spin_lock(&conn->request_lock);
|
||||
list_for_each_entry(iter, command_list, request_entry) {
|
||||
chdr = smb2_get_msg(iter->request_buf);
|
||||
chdr = smb_get_msg(iter->request_buf);
|
||||
|
||||
if (chdr->MessageId != hdr->MessageId ||
|
||||
iter == work)
|
||||
@ -8151,8 +8151,8 @@ int smb2_ioctl(struct ksmbd_work *work)
|
||||
id = work->compound_fid;
|
||||
}
|
||||
} else {
|
||||
req = smb2_get_msg(work->request_buf);
|
||||
rsp = smb2_get_msg(work->response_buf);
|
||||
req = smb_get_msg(work->request_buf);
|
||||
rsp = smb_get_msg(work->response_buf);
|
||||
}
|
||||
|
||||
if (!has_file_id(id))
|
||||
@ -8817,7 +8817,7 @@ int smb2_notify(struct ksmbd_work *work)
|
||||
*/
|
||||
bool smb2_is_sign_req(struct ksmbd_work *work, unsigned int command)
|
||||
{
|
||||
struct smb2_hdr *rcv_hdr2 = smb2_get_msg(work->request_buf);
|
||||
struct smb2_hdr *rcv_hdr2 = smb_get_msg(work->request_buf);
|
||||
|
||||
if ((rcv_hdr2->Flags & SMB2_FLAGS_SIGNED) &&
|
||||
command != SMB2_NEGOTIATE_HE &&
|
||||
@ -8842,7 +8842,7 @@ int smb2_check_sign_req(struct ksmbd_work *work)
|
||||
struct kvec iov[1];
|
||||
size_t len;
|
||||
|
||||
hdr = smb2_get_msg(work->request_buf);
|
||||
hdr = smb_get_msg(work->request_buf);
|
||||
if (work->next_smb2_rcv_hdr_off)
|
||||
hdr = ksmbd_req_buf_next(work);
|
||||
|
||||
@ -8916,7 +8916,7 @@ int smb3_check_sign_req(struct ksmbd_work *work)
|
||||
struct kvec iov[1];
|
||||
size_t len;
|
||||
|
||||
hdr = smb2_get_msg(work->request_buf);
|
||||
hdr = smb_get_msg(work->request_buf);
|
||||
if (work->next_smb2_rcv_hdr_off)
|
||||
hdr = ksmbd_req_buf_next(work);
|
||||
|
||||
@ -9049,7 +9049,7 @@ void smb3_preauth_hash_rsp(struct ksmbd_work *work)
|
||||
static void fill_transform_hdr(void *tr_buf, char *old_buf, __le16 cipher_type)
|
||||
{
|
||||
struct smb2_transform_hdr *tr_hdr = tr_buf + 4;
|
||||
struct smb2_hdr *hdr = smb2_get_msg(old_buf);
|
||||
struct smb2_hdr *hdr = smb_get_msg(old_buf);
|
||||
unsigned int orig_len = get_rfc1002_len(old_buf);
|
||||
|
||||
/* tr_buf must be cleared by the caller */
|
||||
@ -9088,7 +9088,7 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
|
||||
|
||||
bool smb3_is_transform_hdr(void *buf)
|
||||
{
|
||||
struct smb2_transform_hdr *trhdr = smb2_get_msg(buf);
|
||||
struct smb2_transform_hdr *trhdr = smb_get_msg(buf);
|
||||
|
||||
return trhdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM;
|
||||
}
|
||||
@ -9100,7 +9100,7 @@ int smb3_decrypt_req(struct ksmbd_work *work)
|
||||
unsigned int pdu_length = get_rfc1002_len(buf);
|
||||
struct kvec iov[2];
|
||||
int buf_data_size = pdu_length - sizeof(struct smb2_transform_hdr);
|
||||
struct smb2_transform_hdr *tr_hdr = smb2_get_msg(buf);
|
||||
struct smb2_transform_hdr *tr_hdr = smb_get_msg(buf);
|
||||
int rc = 0;
|
||||
|
||||
if (pdu_length < sizeof(struct smb2_transform_hdr) ||
|
||||
@ -9141,7 +9141,7 @@ bool smb3_11_final_sess_setup_resp(struct ksmbd_work *work)
|
||||
{
|
||||
struct ksmbd_conn *conn = work->conn;
|
||||
struct ksmbd_session *sess = work->sess;
|
||||
struct smb2_hdr *rsp = smb2_get_msg(work->response_buf);
|
||||
struct smb2_hdr *rsp = smb_get_msg(work->response_buf);
|
||||
|
||||
if (conn->dialect < SMB30_PROT_ID)
|
||||
return false;
|
||||
|
||||
@ -383,15 +383,6 @@ int smb2_ioctl(struct ksmbd_work *work);
|
||||
int smb2_oplock_break(struct ksmbd_work *work);
|
||||
int smb2_notify(struct ksmbd_work *ksmbd_work);
|
||||
|
||||
/*
|
||||
* Get the body of the smb2 message excluding the 4 byte rfc1002 headers
|
||||
* from request/response buffer.
|
||||
*/
|
||||
static inline void *smb2_get_msg(void *buf)
|
||||
{
|
||||
return buf + 4;
|
||||
}
|
||||
|
||||
#define POSIX_TYPE_FILE 0
|
||||
#define POSIX_TYPE_DIR 1
|
||||
#define POSIX_TYPE_SYMLINK 2
|
||||
|
||||
@ -140,7 +140,7 @@ int ksmbd_verify_smb_message(struct ksmbd_work *work)
|
||||
if (smb2_hdr->ProtocolId == SMB2_PROTO_NUMBER)
|
||||
return ksmbd_smb2_check_message(work);
|
||||
|
||||
hdr = work->request_buf;
|
||||
hdr = smb_get_msg(work->request_buf);
|
||||
if (*(__le32 *)hdr->Protocol == SMB1_PROTO_NUMBER &&
|
||||
hdr->Command == SMB_COM_NEGOTIATE) {
|
||||
work->conn->outstanding_credits++;
|
||||
@ -163,7 +163,7 @@ bool ksmbd_smb_request(struct ksmbd_conn *conn)
|
||||
if (conn->request_buf[0] != 0)
|
||||
return false;
|
||||
|
||||
proto = (__le32 *)smb2_get_msg(conn->request_buf);
|
||||
proto = (__le32 *)smb_get_msg(conn->request_buf);
|
||||
if (*proto == SMB2_COMPRESSION_TRANSFORM_ID) {
|
||||
pr_err_ratelimited("smb2 compression not support yet");
|
||||
return false;
|
||||
@ -259,14 +259,14 @@ int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count)
|
||||
static int ksmbd_negotiate_smb_dialect(void *buf)
|
||||
{
|
||||
int smb_buf_length = get_rfc1002_len(buf);
|
||||
__le32 proto = ((struct smb2_hdr *)smb2_get_msg(buf))->ProtocolId;
|
||||
__le32 proto = ((struct smb2_hdr *)smb_get_msg(buf))->ProtocolId;
|
||||
|
||||
if (proto == SMB2_PROTO_NUMBER) {
|
||||
struct smb2_negotiate_req *req;
|
||||
int smb2_neg_size =
|
||||
offsetof(struct smb2_negotiate_req, Dialects);
|
||||
|
||||
req = (struct smb2_negotiate_req *)smb2_get_msg(buf);
|
||||
req = (struct smb2_negotiate_req *)smb_get_msg(buf);
|
||||
if (smb2_neg_size > smb_buf_length)
|
||||
goto err_out;
|
||||
|
||||
@ -278,15 +278,14 @@ static int ksmbd_negotiate_smb_dialect(void *buf)
|
||||
req->DialectCount);
|
||||
}
|
||||
|
||||
proto = *(__le32 *)((struct smb_hdr *)buf)->Protocol;
|
||||
if (proto == SMB1_PROTO_NUMBER) {
|
||||
struct smb_negotiate_req *req;
|
||||
|
||||
req = (struct smb_negotiate_req *)buf;
|
||||
req = (struct smb_negotiate_req *)smb_get_msg(buf);
|
||||
if (le16_to_cpu(req->ByteCount) < 2)
|
||||
goto err_out;
|
||||
|
||||
if (offsetof(struct smb_negotiate_req, DialectsArray) - 4 +
|
||||
if (offsetof(struct smb_negotiate_req, DialectsArray) +
|
||||
le16_to_cpu(req->ByteCount) > smb_buf_length) {
|
||||
goto err_out;
|
||||
}
|
||||
@ -320,8 +319,8 @@ static u16 get_smb1_cmd_val(struct ksmbd_work *work)
|
||||
*/
|
||||
static int init_smb1_rsp_hdr(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb_hdr *rsp_hdr = (struct smb_hdr *)work->response_buf;
|
||||
struct smb_hdr *rcv_hdr = (struct smb_hdr *)work->request_buf;
|
||||
struct smb_hdr *rsp_hdr = (struct smb_hdr *)smb_get_msg(work->response_buf);
|
||||
struct smb_hdr *rcv_hdr = (struct smb_hdr *)smb_get_msg(work->request_buf);
|
||||
|
||||
rsp_hdr->Command = SMB_COM_NEGOTIATE;
|
||||
*(__le32 *)rsp_hdr->Protocol = SMB1_PROTO_NUMBER;
|
||||
@ -412,9 +411,10 @@ static int init_smb1_server(struct ksmbd_conn *conn)
|
||||
|
||||
int ksmbd_init_smb_server(struct ksmbd_conn *conn)
|
||||
{
|
||||
struct smb_hdr *rcv_hdr = (struct smb_hdr *)smb_get_msg(conn->request_buf);
|
||||
__le32 proto;
|
||||
|
||||
proto = *(__le32 *)((struct smb_hdr *)conn->request_buf)->Protocol;
|
||||
proto = *(__le32 *)rcv_hdr->Protocol;
|
||||
if (conn->need_neg == false) {
|
||||
if (proto == SMB1_PROTO_NUMBER)
|
||||
return -EINVAL;
|
||||
@ -572,12 +572,12 @@ static int __smb2_negotiate(struct ksmbd_conn *conn)
|
||||
|
||||
static int smb_handle_negotiate(struct ksmbd_work *work)
|
||||
{
|
||||
struct smb_negotiate_rsp *neg_rsp = work->response_buf;
|
||||
struct smb_negotiate_rsp *neg_rsp = smb_get_msg(work->response_buf);
|
||||
|
||||
ksmbd_debug(SMB, "Unsupported SMB1 protocol\n");
|
||||
|
||||
if (ksmbd_iov_pin_rsp(work, (void *)neg_rsp + 4,
|
||||
sizeof(struct smb_negotiate_rsp) - 4))
|
||||
if (ksmbd_iov_pin_rsp(work, (void *)neg_rsp,
|
||||
sizeof(struct smb_negotiate_rsp)))
|
||||
return -ENOMEM;
|
||||
|
||||
neg_rsp->hdr.Status.CifsError = STATUS_SUCCESS;
|
||||
|
||||
@ -203,4 +203,13 @@ unsigned int ksmbd_server_side_copy_max_chunk_size(void);
|
||||
unsigned int ksmbd_server_side_copy_max_total_size(void);
|
||||
bool is_asterisk(char *p);
|
||||
__le32 smb_map_generic_desired_access(__le32 daccess);
|
||||
|
||||
/*
|
||||
* Get the body of the smb message excluding the 4 byte rfc1002 headers
|
||||
* from request/response buffer.
|
||||
*/
|
||||
static inline void *smb_get_msg(void *buf)
|
||||
{
|
||||
return buf + 4;
|
||||
}
|
||||
#endif /* __SMB_SERVER_COMMON_H__ */
|
||||
|
||||
@ -371,6 +371,7 @@ struct software_node_ref_args {
|
||||
(const struct software_node_ref_args) { \
|
||||
.swnode = _Generic(_ref_, \
|
||||
const struct software_node *: _ref_, \
|
||||
struct software_node *: _ref_, \
|
||||
default: NULL), \
|
||||
.fwnode = _Generic(_ref_, \
|
||||
struct fwnode_handle *: _ref_, \
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
#include <linux/completion.h>
|
||||
#include <linux/virtio_features.h>
|
||||
|
||||
struct module;
|
||||
|
||||
/**
|
||||
* struct virtqueue - a queue to register buffers for sending or receiving.
|
||||
* @list: the chain of virtqueues for this device
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
#define _LINUX_VIRTIO_FEATURES_H
|
||||
|
||||
#include <linux/bits.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#define VIRTIO_FEATURES_U64S 2
|
||||
#define VIRTIO_FEATURES_BITS (VIRTIO_FEATURES_U64S * 64)
|
||||
|
||||
@ -73,13 +73,13 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
|
||||
open->filename = NULL;
|
||||
return ret;
|
||||
}
|
||||
req->flags |= REQ_F_NEED_CLEANUP;
|
||||
|
||||
open->file_slot = READ_ONCE(sqe->file_index);
|
||||
if (open->file_slot && (open->how.flags & O_CLOEXEC))
|
||||
return -EINVAL;
|
||||
|
||||
open->nofile = rlimit(RLIMIT_NOFILE);
|
||||
req->flags |= REQ_F_NEED_CLEANUP;
|
||||
if (io_openat_force_async(open))
|
||||
req->flags |= REQ_F_FORCE_ASYNC;
|
||||
return 0;
|
||||
|
||||
@ -1599,6 +1599,7 @@ void kthread_use_mm(struct mm_struct *mm)
|
||||
|
||||
WARN_ON_ONCE(!(tsk->flags & PF_KTHREAD));
|
||||
WARN_ON_ONCE(tsk->mm);
|
||||
WARN_ON_ONCE(!mm->user_ns);
|
||||
|
||||
/*
|
||||
* It is possible for mm to be the same as tsk->active_mm, but
|
||||
|
||||
@ -19,3 +19,24 @@ int rust_helper_dma_set_mask_and_coherent(struct device *dev, u64 mask)
|
||||
{
|
||||
return dma_set_mask_and_coherent(dev, mask);
|
||||
}
|
||||
|
||||
int rust_helper_dma_set_mask(struct device *dev, u64 mask)
|
||||
{
|
||||
return dma_set_mask(dev, mask);
|
||||
}
|
||||
|
||||
int rust_helper_dma_set_coherent_mask(struct device *dev, u64 mask)
|
||||
{
|
||||
return dma_set_coherent_mask(dev, mask);
|
||||
}
|
||||
|
||||
int rust_helper_dma_map_sgtable(struct device *dev, struct sg_table *sgt,
|
||||
enum dma_data_direction dir, unsigned long attrs)
|
||||
{
|
||||
return dma_map_sgtable(dev, sgt, dir, attrs);
|
||||
}
|
||||
|
||||
size_t rust_helper_dma_max_mapping_size(struct device *dev)
|
||||
{
|
||||
return dma_max_mapping_size(dev);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ impl SampleDriver {
|
||||
// Select the test.
|
||||
bar.write8(index.0, Regs::TEST);
|
||||
|
||||
let offset = u32::from_le(bar.read32(Regs::OFFSET)) as usize;
|
||||
let offset = bar.read32(Regs::OFFSET) as usize;
|
||||
let data = bar.read8(Regs::DATA);
|
||||
|
||||
// Write `data` to `offset` to increase `count` by one.
|
||||
|
||||
@ -20,8 +20,9 @@ CFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../
|
||||
CFLAGS += -pthread
|
||||
LDFLAGS += -pthread
|
||||
vpath %.c ../../drivers/virtio ../../drivers/vhost
|
||||
BUILD=KCFLAGS="-I "`pwd`/../../drivers/vhost ${MAKE} -C `pwd`/../.. V=${V}
|
||||
mod:
|
||||
${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
|
||||
${BUILD} M=`pwd`/vhost_test
|
||||
|
||||
#oot: build vhost as an out of tree module for a distro kernel
|
||||
#no effort is taken to make it actually build or work, but tends to mostly work
|
||||
@ -37,8 +38,9 @@ OOT_CONFIGS=\
|
||||
CONFIG_VHOST_NET=n \
|
||||
CONFIG_VHOST_SCSI=n \
|
||||
CONFIG_VHOST_VSOCK=n \
|
||||
CONFIG_VHOST_RING=n
|
||||
OOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
|
||||
CONFIG_VHOST_RING=n \
|
||||
CONFIG_VHOST_VDPA=n
|
||||
OOT_BUILD=KCFLAGS="-include "`pwd`"/oot-stubs.h -I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
|
||||
oot-build:
|
||||
echo "UNSUPPORTED! Don't use the resulting modules in production!"
|
||||
${OOT_BUILD} M=`pwd`/vhost_test
|
||||
|
||||
@ -2,7 +2,11 @@
|
||||
#ifndef LINUX_COMPILER_H
|
||||
#define LINUX_COMPILER_H
|
||||
|
||||
/* Avoid redefinition warnings */
|
||||
#undef __user
|
||||
#include "../../../include/linux/compiler_types.h"
|
||||
#undef __user
|
||||
#define __user
|
||||
|
||||
#define WRITE_ONCE(var, val) \
|
||||
(*((volatile typeof(val) *)(&(var))) = (val))
|
||||
@ -35,4 +39,6 @@
|
||||
__v; \
|
||||
})
|
||||
|
||||
#define __must_check
|
||||
|
||||
#endif
|
||||
|
||||
@ -4,4 +4,8 @@
|
||||
|
||||
#include <linux/kernel.h>
|
||||
|
||||
struct cpumask {
|
||||
unsigned long bits[1];
|
||||
};
|
||||
|
||||
#endif /* _LINUX_CPUMASK_H */
|
||||
|
||||
@ -1,2 +1,10 @@
|
||||
#ifndef LINUX_DEVICE_H
|
||||
|
||||
struct device {
|
||||
void *parent;
|
||||
};
|
||||
|
||||
struct device_driver {
|
||||
const char *name;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -22,6 +22,7 @@ enum dma_data_direction {
|
||||
#define dma_free_coherent(d, s, p, h) kfree(p)
|
||||
|
||||
#define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o))
|
||||
#define dma_map_page_attrs(d, p, o, s, dir, a) (page_to_phys(p) + (o))
|
||||
|
||||
#define dma_map_single(d, p, s, dir) (virt_to_phys(p))
|
||||
#define dma_map_single_attrs(d, p, s, dir, a) (virt_to_phys(p))
|
||||
@ -29,6 +30,9 @@ enum dma_data_direction {
|
||||
|
||||
#define dma_unmap_single(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
|
||||
#define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
|
||||
#define dma_unmap_page_attrs(d, a, s, r, t) do { \
|
||||
(void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
|
||||
} while (0)
|
||||
|
||||
#define sg_dma_address(sg) (0)
|
||||
#define sg_dma_len(sg) (0)
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <linux/log2.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/overflow.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/bug.h>
|
||||
@ -135,6 +136,21 @@ static inline void *krealloc_array(void *p, size_t new_n, size_t new_size, gfp_t
|
||||
#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
|
||||
#define dev_warn_once(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
|
||||
|
||||
#define dev_WARN_ONCE(dev, condition, format...) \
|
||||
WARN_ONCE(condition, format)
|
||||
|
||||
static inline bool is_vmalloc_addr(const void *x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#define might_sleep() do { } while (0)
|
||||
|
||||
static inline void synchronize_rcu(void)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
#define min(x, y) ({ \
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <linux/export.h>
|
||||
|
||||
struct module;
|
||||
|
||||
#define MODULE_LICENSE(__MODULE_LICENSE_value) \
|
||||
static __attribute__((unused)) const char *__MODULE_LICENSE_name = \
|
||||
__MODULE_LICENSE_value
|
||||
|
||||
21
tools/virtio/linux/ucopysize.h
Normal file
21
tools/virtio/linux/ucopysize.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __LINUX_UCOPYSIZE_H__
|
||||
#define __LINUX_UCOPYSIZE_H__
|
||||
|
||||
#include <linux/bug.h>
|
||||
|
||||
static inline void check_object_size(const void *ptr, unsigned long n,
|
||||
bool to_user)
|
||||
{ }
|
||||
|
||||
static inline void copy_overflow(int size, unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
static __always_inline __must_check bool
|
||||
check_copy_size(const void *addr, size_t bytes, bool is_source)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* __LINUX_UCOPYSIZE_H__ */
|
||||
@ -1,72 +1 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef LINUX_VIRTIO_H
|
||||
#define LINUX_VIRTIO_H
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
struct device {
|
||||
void *parent;
|
||||
};
|
||||
|
||||
struct virtio_device {
|
||||
struct device dev;
|
||||
u64 features;
|
||||
struct list_head vqs;
|
||||
spinlock_t vqs_list_lock;
|
||||
const struct virtio_config_ops *config;
|
||||
};
|
||||
|
||||
struct virtqueue {
|
||||
struct list_head list;
|
||||
void (*callback)(struct virtqueue *vq);
|
||||
const char *name;
|
||||
struct virtio_device *vdev;
|
||||
unsigned int index;
|
||||
unsigned int num_free;
|
||||
unsigned int num_max;
|
||||
void *priv;
|
||||
bool reset;
|
||||
};
|
||||
|
||||
/* Interfaces exported by virtio_ring. */
|
||||
int virtqueue_add_sgs(struct virtqueue *vq,
|
||||
struct scatterlist *sgs[],
|
||||
unsigned int out_sgs,
|
||||
unsigned int in_sgs,
|
||||
void *data,
|
||||
gfp_t gfp);
|
||||
|
||||
int virtqueue_add_outbuf(struct virtqueue *vq,
|
||||
struct scatterlist sg[], unsigned int num,
|
||||
void *data,
|
||||
gfp_t gfp);
|
||||
|
||||
int virtqueue_add_inbuf(struct virtqueue *vq,
|
||||
struct scatterlist sg[], unsigned int num,
|
||||
void *data,
|
||||
gfp_t gfp);
|
||||
|
||||
bool virtqueue_kick(struct virtqueue *vq);
|
||||
|
||||
void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
|
||||
|
||||
void virtqueue_disable_cb(struct virtqueue *vq);
|
||||
|
||||
bool virtqueue_enable_cb(struct virtqueue *vq);
|
||||
bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
|
||||
|
||||
void *virtqueue_detach_unused_buf(struct virtqueue *vq);
|
||||
struct virtqueue *vring_new_virtqueue(unsigned int index,
|
||||
unsigned int num,
|
||||
unsigned int vring_align,
|
||||
struct virtio_device *vdev,
|
||||
bool weak_barriers,
|
||||
bool ctx,
|
||||
void *pages,
|
||||
bool (*notify)(struct virtqueue *vq),
|
||||
void (*callback)(struct virtqueue *vq),
|
||||
const char *name);
|
||||
void vring_del_virtqueue(struct virtqueue *vq);
|
||||
|
||||
#endif
|
||||
#include <../../include/linux/virtio.h>
|
||||
|
||||
@ -1,101 +1 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef LINUX_VIRTIO_CONFIG_H
|
||||
#define LINUX_VIRTIO_CONFIG_H
|
||||
#include <linux/virtio_byteorder.h>
|
||||
#include <linux/virtio.h>
|
||||
#include <uapi/linux/virtio_config.h>
|
||||
|
||||
struct virtio_config_ops {
|
||||
int (*disable_vq_and_reset)(struct virtqueue *vq);
|
||||
int (*enable_vq_after_reset)(struct virtqueue *vq);
|
||||
};
|
||||
|
||||
/*
|
||||
* __virtio_test_bit - helper to test feature bits. For use by transports.
|
||||
* Devices should normally use virtio_has_feature,
|
||||
* which includes more checks.
|
||||
* @vdev: the device
|
||||
* @fbit: the feature bit
|
||||
*/
|
||||
static inline bool __virtio_test_bit(const struct virtio_device *vdev,
|
||||
unsigned int fbit)
|
||||
{
|
||||
return vdev->features & (1ULL << fbit);
|
||||
}
|
||||
|
||||
/**
|
||||
* __virtio_set_bit - helper to set feature bits. For use by transports.
|
||||
* @vdev: the device
|
||||
* @fbit: the feature bit
|
||||
*/
|
||||
static inline void __virtio_set_bit(struct virtio_device *vdev,
|
||||
unsigned int fbit)
|
||||
{
|
||||
vdev->features |= (1ULL << fbit);
|
||||
}
|
||||
|
||||
/**
|
||||
* __virtio_clear_bit - helper to clear feature bits. For use by transports.
|
||||
* @vdev: the device
|
||||
* @fbit: the feature bit
|
||||
*/
|
||||
static inline void __virtio_clear_bit(struct virtio_device *vdev,
|
||||
unsigned int fbit)
|
||||
{
|
||||
vdev->features &= ~(1ULL << fbit);
|
||||
}
|
||||
|
||||
#define virtio_has_feature(dev, feature) \
|
||||
(__virtio_test_bit((dev), feature))
|
||||
|
||||
/**
|
||||
* virtio_has_dma_quirk - determine whether this device has the DMA quirk
|
||||
* @vdev: the device
|
||||
*/
|
||||
static inline bool virtio_has_dma_quirk(const struct virtio_device *vdev)
|
||||
{
|
||||
/*
|
||||
* Note the reverse polarity of the quirk feature (compared to most
|
||||
* other features), this is for compatibility with legacy systems.
|
||||
*/
|
||||
return !virtio_has_feature(vdev, VIRTIO_F_ACCESS_PLATFORM);
|
||||
}
|
||||
|
||||
static inline bool virtio_is_little_endian(struct virtio_device *vdev)
|
||||
{
|
||||
return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
|
||||
virtio_legacy_is_little_endian();
|
||||
}
|
||||
|
||||
/* Memory accessors */
|
||||
static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val)
|
||||
{
|
||||
return __virtio16_to_cpu(virtio_is_little_endian(vdev), val);
|
||||
}
|
||||
|
||||
static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val)
|
||||
{
|
||||
return __cpu_to_virtio16(virtio_is_little_endian(vdev), val);
|
||||
}
|
||||
|
||||
static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val)
|
||||
{
|
||||
return __virtio32_to_cpu(virtio_is_little_endian(vdev), val);
|
||||
}
|
||||
|
||||
static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val)
|
||||
{
|
||||
return __cpu_to_virtio32(virtio_is_little_endian(vdev), val);
|
||||
}
|
||||
|
||||
static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val)
|
||||
{
|
||||
return __virtio64_to_cpu(virtio_is_little_endian(vdev), val);
|
||||
}
|
||||
|
||||
static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
|
||||
{
|
||||
return __cpu_to_virtio64(virtio_is_little_endian(vdev), val);
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "../../include/linux/virtio_config.h"
|
||||
|
||||
10
tools/virtio/oot-stubs.h
Normal file
10
tools/virtio/oot-stubs.h
Normal file
@ -0,0 +1,10 @@
|
||||
#include <linux/bug.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/virtio_features.h>
|
||||
|
||||
#ifndef VIRTIO_FEATURES_BITS
|
||||
#define VIRTIO_FEATURES_BITS 128
|
||||
#endif
|
||||
#ifndef VIRTIO_U64
|
||||
#define VIRTIO_U64(b) ((b) >> 6)
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user