KMDF Passing Information Between PCIe Device Objects

Background

I am working on a KMDF driver for a PCIe device we are developing. One of the features required is to perform autonomous P2P transfer of data between the devices and I am trying to figure out a reasonable way to implement the API for this. All devices use the same custom KMDF driver (they can dynamically change between sender or receiver) and are simply appearing as individual device objects for that same driver.

The devices themselves (FPGAs) have their own DMA engines and bus-mastering capabilities. For testing purposes, I implemented a very simple way of controlling this using a couple of IOCTL codes. For the receiving device, an IOCTL for the driver returns a bus-relative address of the receive buffer in that FPGA. For the sending device a second IOCTL is implemented to which the address of the target device is provided. The sender then performs DMA operations to this target address.

However as we move out of development into a release oriented driver, this approach seems highly unsafe and insecure. It basically provides a kernel API that can instruct the device to write to arbitrary memory addresses that are provided by the user land (user software relays the address information from one instance to another).

Question

There must be a better way of doing this. The first thought was some sort of encryption or signing of the address, but this feels like just patching over a poor design to make it feel safer.

I imagine a better way is to keep the addressing completely in kernel land, and instead return some form of unique target ID for the receiver device to user land. When the sender driver instance is provided the target ID, it would then need to find some way of looking up the actual bus address for that device. This would require the different device device instances to be able to communicate with each other to perform the address lookup.

Unfortunately I’m not familiar enough with the KMDF framework to figure out an approprate way of implementing this communication, so some pointers would be appreciated. Specifically the bits I’m missing:

  1. Assigning a unique ID to each instance of the driver.

    • I was thinking either some sort of shared counter in the driver that tracks how many instances have been created,
    • Alternatively if there is a way of looking up say the PCIe bus-device-function address of the receiver and using that as an ID.
    • Maybe I’m over thinking it and the framework might already have some ID for each instance that I could use directly.
  2. Communication between different instances of the driver to perform address lookup.

    • I could add an internal API to the driver, or store address information in each device context, but I would need to find a way to find the device context from an ID.

Ideally I would like this to work with KMDF framework versions as old as 1.11 as we still have a system connected to an old Win 7 machine (non-networked) that can’t be updated yet for other reasons. But I would be OK with it working with version 1.15.

If possible I’d like to avoid having to deal with playing with with the underlying WDM objects and stick with well documented KMDF APIs.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật